nginx配置webSocket转发
一、连接webSocket后台报Handshake failed due to invalid Upgrade header: null 解决方案
解决办法:在 nginx的location 中添加以下代码:
proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade";
例如:
location /strong_learning_police_czys_yanshi/ { proxy_pass http://192.168.0.247:6610/strong_learning_police_czys_yanshi/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 1000M; proxy_read_timeout 1800s; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; }