WebSocket部署之Nginx配置
upstream ws {
server 127.0.0.1:9091;
server 127.0.0.1:9099;
ip_hash;
}
server {
listen 80;
server_name ws.xxx.com;
access_log /data/wwwlogs/ws.xxx.com_nginx.log combined;
root /data/wwwroot/ws.xxx.com;
location ~ /\.ht {
deny all;
}
location ~ {
proxy_pass http://ws;
include proxy.conf;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
***配置以下行才能直接用80端口访问
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";