【发布时间】:2014-08-18 15:44:47
【问题描述】:
我使用 Nginx 作为反向代理,它接受请求,然后执行 proxy_pass 从运行在端口 8001 上的上游服务器获取实际的 Web 应用程序。
如果我访问 mywebsite.com 或执行 wget,我会在 60 秒后收到 504 Gateway Timeout... 但是,如果我加载 mywebsite.com:8001,应用程序会按预期加载!
所以有些东西阻止了 Nginx 与上游服务器通信。
这一切都是在我的托管公司重置运行我的东西的机器之后开始的,在此之前没有任何问题。
这是我的虚拟主机服务器块:
server {
listen 80;
server_name mywebsite.com;
root /home/user/public_html/mywebsite.com/public;
access_log /home/user/public_html/mywebsite.com/log/access.log upstreamlog;
error_log /home/user/public_html/mywebsite.com/log/error.log;
location / {
proxy_pass http://xxx.xxx.xxx.xxx:8001;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
以及我的 Nginx 错误日志的输出:
2014/06/27 13:10:58 [error] 31406#0: *1 upstream timed out (110: Connection timed out) while connecting to upstream, client: xxx.xx.xxx.xxx, server: mywebsite.com, request: "GET / HTTP/1.1", upstream: "http://xxx.xxx.xxx.xxx:8001/", host: "mywebsite.com"
【问题讨论】:
-
服务器是否运行 SELinux?
-
在我的案例中,问题在于 NAT 网关,而不是 NGINX 或后端 API。 stackoverflow.com/a/62351959/9956279
标签: nginx reverse-proxy proxypass http-status-code-504