【发布时间】:2012-09-08 05:52:20
【问题描述】:
我正在尝试让 nginx 为某个子目录下的请求提供静态文件,但没有运气(得到 404),而所有其他请求都是反向代理的。例如,我希望对 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;
}
}
【问题讨论】:
标签: nginx reverse-proxy