nginx转发不支持 websocket原因

2021-04-02 09:33:51 浏览数 (1)

代码语言:javascript复制
Upgrade: websocket

关键参数:Upgrade

nginx在反向代理的时候 少转发了头,添加上就可以了。

代码语言:javascript复制
       proxy_set_header Upgrade $http_upgrade;
           proxy_set_header Connection "upgrade";

完整配置:

代码语言:javascript复制
location / { 
           proxy_pass http://cluster;
           client_max_body_size 500M;
           client_body_buffer_size 10M;
           fastcgi_intercept_errors on;
           proxy_connect_timeout   60;
           proxy_send_timeout      60;
           proxy_read_timeout      60;
           proxy_http_version       1.1;                    
           proxy_set_header Upgrade $http_upgrade;
           proxy_set_header Connection "upgrade";
        }

0 人点赞