Handshake failed due to invalid Upgrade header: null 解决方案

Handshake failed due to invalid Upgrade header: null 解决方案

解决方案,在 Nginx ,location 中添加以下代码:

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection  "upgrade";
server {
        listen 80;
        server_name localhost;
 
 
        location / {
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $http_host;
                proxy_set_header X-NginX-Proxy true;
 
                # prevents 502 bad gateway error
                proxy_buffers 8 32k;
                proxy_buffer_size 64k;
 
                proxy_pass http://127.0.0.1:8080;
                proxy_redirect off;
 
                # enables WS support
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection  "upgrade";
        }
}
posted @ 2019-02-21 16:03  木易森林  阅读(2700)  评论(0编辑  收藏  举报