I am trying, without luck (getting 404s), to get nginx to serve static files for requests under a certain subdirectory, while all other requests are reversed-proxied. For example, I want requests to http://example.com/project/static/index.html, and http://example.com/project/static/subdir/file2.html to map to /var/www/example.com/htdocs/index.html and /var/www/example.com/htdocs/subdir/file2.html respectively.
All other requests should be reversed-proxied. For example, http://example.com/project/thisWillBeProxied.html and http://example.com/project/subdir/soWillThis.html
Here is my active nginx profile
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;
}
}