Nginx 支持websocket的配置

Nginx 支持websocket的配置

server {
      listen   80;
      server_name 域名;
      location / {
        proxy_pass   http://127.0.0.1:23888/; // 代理转发地址
        // 启用支持websocket连接
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
      }
}

重要的是这两行,它表明是websocket连接进入的时候,进行一个连接升级将http连接变成websocket的连接。

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection "upgrade";

你可能感兴趣的:(nginx,服务环境)