【发布时间】:2012-02-20 11:08:42
【问题描述】:
我一直在将 Nginx 设置为服务器上应用程序的反向代理。其中一部分包括具有外部内容(如图像)的维护页面。我能够找到一种方法来设置返回 200 的图像的错误页面,但看起来反向代理会改变整个环境。这是nginx maintenance page with content issue的原始解决方案
error_page 503 @maintenance;
location @maintenance {
root /path_to_static_root;
if (!-f $request_filename) {
rewrite ^(.*)$ /rest_of_path/maintenance.html break;
}
return 200;
}
反向代理配置为:
location / {
proxy_pass http://127.0.0.1:9007/;
proxy_redirect off;
}
问题是当发现“维护”根目录中存在文件时,出现问题,服务器返回 502。有人知道可能是什么原因吗?
一些猜测 我想知道服务器是否侦听端口 80,它以某种方式将任何好的文件请求传递回代理。如果是真的,如何避免?
编辑
这是 nginx 日志中的错误。我直接尝试访问 50x.html。不知道为什么会这样?
2012/02/17 19:39:15 [error] 21394#0: *13 connect() failed (111: Connection refused) while connecting to upstream, client: (my ip address), server: _, request: "GET /50x.html HTTP/1.1", upstream: "http://127.0.0.1:9007/50x.html", host: "domain.com"
看起来是确实试图从应用程序而不是根目录获取。我怎样才能绕过这个?
编辑 2
我原本以为我找到了对 nginx v1.0.12 进行更改的答案,但它并没有解决问题。它涉及类似的情况,但我的猜测是修复太具体了。
【问题讨论】:
标签: nginx