
다음과 같이 도메인 하위 디렉터리에 있는 다른 문서 루트의 다른 소프트웨어를 제공하도록 nginx를 구성해야 합니다.
http://example.com/... - main site from /var/www/main
http://example.com/docs/ - an independent application from /var/www/app
나는 Proxy_pass 및 alias를 포함하여 여러 가지 방법을 시도했지만 그 중 어느 것도 나에게 도움이 되지 않았습니다. 최신 구성은 다음과 같습니다.
server {
listen 80;
server_name example.com;
root /var/www/main;
index index.html;
location /docs/ {
root /var/www/app;
}
}
접속하려고 하면http://example.com/docs/error_log에 404 Not Found 오류와 다음 메시지가 표시됩니다.
*1 "/var/www/app/docs/index.html"을 찾을 수 없습니다(2: 해당 파일이나 디렉터리가 없습니다).
/var/www/app/docs/index.html
그래서 대신 열려고 시도합니다 /var/www/app/index.html
.
rewrite
나는 이 문제가 다음과 같은 방법으로 해결될 수 있다는 것을 알고 있습니다 rewrite ^/docs/(.*)$ /$1 last;
. 그것은 나에게 효과적이지만 모든 자산에 대한 모든 상대 링크를 다시 작성하므로 그렇지 않습니다.
업데이트:
1) 내 문제 alias
:
location /docs/ {
autoindex on;
alias /var/www/app/;
}
"/var/www/app/index.html"을 찾을 수 없습니다(2: 해당 파일이나 디렉터리가 없음).
2) Proxy_pass 문제:
location /docs/ {
proxy_pass: http://127.0.0.1:8080;
}
...
server {
listen 8080;
server_name localhost;
root /var/www/app;
index index.html;
}
오류는 다음과 같습니다.
/var/www/app/docs/index.html" is not found (2: No such file or directory)