异常为:WebSocket connection to 'ws://...' failed: Error during WebSocket handshake: Unexpected response code: 200
此时,需要nginx配置支持websocket协议ws://,正确的nginx配置为:
location /api/ {
rewrite ^/api/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:8585;
...
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
网友评论