他のすべてのリクエストがリバースプロキシされている間、運が悪い(404を取得する)ために、nginxが特定のサブディレクトリの下のリクエストに対して静的ファイルを提供するようにしようとしています。たとえば、http://example.com/project/static/index.htmlおよびhttp://example.com/project/static/subdir/file2.htmlへのリクエストを /var/www/example にマップする必要がありますそれぞれ .com/htdocs/index.html と /var/www/example.com/htdocs/subdir/file2.html です。
他のすべてのリクエストはリバース プロキシする必要があります。たとえば、http://example.com/project/thisWillBeProxied.htmlおよびhttp://example.com/project/subdir/soWillThis.html
これが私のアクティブなnginxプロファイルです
server {
listen 8080;
server_name example.com;
access_log /var/www/example.com/log/nginx.access.log;
error_log /var/www/example.com/log/nginx_error.log debug;
location / {
proxy_pass http://reverse-proxy-host/;
}
location ^~ /project/static/ {
alias /var/www/example.com/htdocs;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/nginx-default;
}
}