客户端没有使用websocket协议:'upgrade'令牌未在'Connection'头中找到

错误:websocket: the client is not using the websocket protocol: ‘upgrade’ token not found in ‘Connection’ head 当反向代理或负载平衡器未正确传递 WebSocket 请求时,就会出现此问题。以下是解决此问题的说明。 For Nginx

1
2
3
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade

For Apache:

1
2
3
4
 <Location /ws>
     ProxyPass ws://localhost:8000
     ProxyPassReverse ws://localhost:8000/
 </Location>
Licensed under CC BY-NC-SA 4.0
最后更新于 Jan 06, 2025 05:52 UTC
comments powered by Disqus
Built with Hugo
主题 StackJimmy 设计
Caret Up