我很少有带有专用网络的 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 台机器,但第三台仅给出 502 和 nginx 错误日志:
[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),而其他服务器没有。
您的 nginx 服务器和后端服务器之间存在网络问题。这可能是由于这两者之间的防火墙或路由问题造成的。