快速分解 -
开发环境正常运行。本地服务器上的SSL证书,配置为代理的nginx传递443流量。
location / {
proxy_pass http://localhost:3000;
proxy_set_header X-Real-IP $remote_addr;
#proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
由于某种原因,版本1.1永远不会工作(总是抛出错误)
同样,Dev环境正常运行。
生产环境给我以下错误:
与'wss://website.com/sockjs/421/fin4cg38/websocket'的WebSocket连接失败:WebSocket握手期间出错:意外响应代码:400
我使用了具有SSL证书的负载均衡器,并通过我们的应用程序强制执行SSL。
现在,我检查了NGINX的配置,我有如下:
server {
listen 80;
server_name www.website.com;
error_log /var/log/nginx/sites-error.log;
return 301 https://website.com$request_uri;
}
server {
listen 80 default_server;
server_name _;
location / {
proxy_pass http://localhost:3000;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection "upgrade";
它的设置方式是80上的任何东西都是443等等。
如果我取消注释proxy_set_headers,我们的注册会中断并且Chrome控制台不会显示任何错误。
错误日志有这个:
2014/07/13 18:15:16 [error] 16175#0: *93 connect() failed (111: Connection refused) while connecting to upstream, client: 10.189.245.5, server: _, request: "POST /sockjs/421/wq2dqb2w/xhr_send HTTP/1.1", upstream: "http://[::1]:3000/sockjs/421/wq2dqb2w/xhr_send", host: "website.com", referrer: "https://website.com/signIn"
2014/07/13 18:15:42 [error] 16487#0: *3 connect() failed (111: Connection refused) while connecting to upstream, client: 10.189.245.5, server: _, request: "GET /sockjs/120/95m6dozn/websocket HTTP/1.1", upstream: "http://[::1]:3000/sockjs/120/95m6dozn/websocket", host: "website.com"
2014/07/13 18:16:12 [error] 16487#0: *12 connect() failed (111: Connection refused) while connecting to upstream, client: 10.189.245.5, server: _, request: "GET /f1be3f98162c975fdc9524a0a222f9a02cc6dcde.js HTTP/1.1", upstream: "http://[::1]:3000/f1be3f98162c975fdc9524a0a222f9a02cc6dcde.js", host: "website.com", referrer: "https://website.com/signIn"
我不确定发生了什么。任何帮助都会很棒。
谢谢!