在 nginx 中配置好 https 协议之后,连接 websocket 用 wss,结果报错:400 bad request。
解决方法
NGINX 原来的配置:
1 2 3
| location / { proxy_pass http://nodesrv; }
|
需加多几条配置,如下:
1 2 3 4 5 6 7 8 9 10 11 12
| location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_pass http://nodesrv; }
|
参考资料