您的位置 首页 nginx

nginx 配置 websocket

websocket  长链接 配置

解决nginx转发websocket报400错误

解决nginx转发websocket报400错误_error: unexpected server response: 400-CSDN博客

 

其中最重要的是下面这三行

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
其中第一行是告诉nginx使用HTTP/1.1通信协议,这是websoket必须要使用的协议。

第二行和第三行告诉nginx,当它想要使用WebSocket时,响应http升级请求。

 

server {
	listen 8191;
	server_name uat-baimeidashu.com;
        location / {
            proxy_pass http://192.168.1.209:31805;
            include proxy_params;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
          }        
}

 

 

欢迎来撩 : 汇总all

白眉大叔

关于白眉大叔linux云计算: 白眉大叔

热门文章