我有几台带私有网络的 vps 机器。我在所有机器上都使用 nginx 代理传递请求到第四台机器 (10.129.xxx.xxx),该机器仅监听私有连接。
我只是从这个配置中更改了 server_name:s,但除此之外它们是相同的:
upstream panel { server 10.129.xxx.xxx:8000; }
server {
listen 80;
server_name *.example.com example.com;
return 301 https://$host$request_uri;
}
server {
listen 443;
server_name *.example.com example.com;
ssl on;
ssl_certificate /etc/private/ssl/server.crt;
ssl_certificate_key /etc/private/ssl/server.key;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:AES128-GCM-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH:!CAMELLIA;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://panel;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Request-Start $msec;
}
}
此设置在 2 台机器上有效,但第三台机器仅给出 nginx 错误日志 502:
[error] 31890#0: *27 connect() failed (111: Connection refused) while connecting to upstream, client: 123.456.70.80, server: *.example.com, request: "GET / HTTP/1.1", upstream: "http://10.129.xxx.xx:8000/error/50x.html", host: "example.com"
哪些 nginx 规则可能导致此问题?防火墙?我应该在哪里查找此错误?出现错误的服务器安装了 vestacp-panel 和 apache(端口 8080),而其他服务器没有。
答案1
您的 nginx 服务器和后端服务器之间存在网络问题。这可能是由于两者之间的防火墙或路由问题造成的。