Nginx对WebSocket进行负载均衡

Nginx对WebSocket进行负载均衡

  •  11个月前
  •  413
  •  Nginx WebSocket 

NGINX supports WebSocket by allowing a tunnel to be set up between a client and a backend server. For NGINX to send the Upgrade request from the client to the backend server, the Upgrade and Connection headers must be set explicitly.

配置文件

location /wsapp/ {
    proxy_pass http://wsbackend;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
}

参考:https://www.nginx.com/blog/websocket-nginx/


扫一扫分享到微信

已有 条评论
写评论