部署到Linux后,出现问题:
WebSocket connection to failed: Error during WebSocket handshake: Unexpected response code: 200
原因是服务器使用Nginx不支持websocket,但Nginx可用代理Websocket连接,需要做如下配置:
location / { proxy_pass http://backend; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; }
但我们修改后会出现问题,我么之前正常的请求,都变成了400 Bad Request
我们想方法变通下,独立出SingR的请求配置
location / {
proxy_pass http://backend;
proxy_http_version 1.1;
}
location /chatHub {
proxy_pass http://backend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
这样就可用了。