[版权声明] 本站内容采用 知识共享署名-非商业性使用-相同方式共享 3.0 中国大陆 (CC BY-NC-SA 3.0 CN) 进行许可。
部分内容和资源来自网络,纯学习研究使用。如有侵犯您的权益,请及时联系我,我将尽快处理。
如转载请注明来自: Broly的博客,本文链接: nginx使用wss协议出现400错误
在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; } |
参考链接:《nginx使用wss协议出现wss handshake: Unexpected response code: 400》