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";
posted @ 2022-04-20 22:09  rubekid  阅读(254)  评论(0编辑  收藏  举报