以下是我的应用代理流程:
nginx(host-a:80) - > haproxy(host-b:5000) - > socket.io app(host-c:3000)
我可以通过haproxy(host-b:5000)访问该应用程序,它运行正常,http可以升级到套接字连接。
然而,当我通过nginx(host-a:80)访问时它失败了。
location /socket.io {
proxy_pass http://node_server_pool;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /socket.io {
proxy_pass http://node_server_pool;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Connection "";
proxy_http_version 1.1;
proxy_redirect off;
}
是否可以像这样在套接字代理服务器前面运行nginx?