在使用nginx进行端口转发时,使用了websocket,但出现错误:
websocket: the client is not using the websocket protocol: ‘upgrade’ token not found in ‘Connection’ head
当反向代理或负载平衡器未正确传递WebSocket请求时,就会出现此问题。以下是解决此问题的说明。
For Nginx:
proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection upgrade
For Apache:
<Location /ws> ProxyPass ws://localhost:8000 ProxyPassReverse ws://localhost:8000/