宝塔利用nginx代理转发socket服务器


配置文件头部加入:

    map $http_upgrade $connection_upgrade {

        default upgrade;

        '' close;

    }

    upstream websocket {

        server 127.0.0.1:19600; #这里可以是多个服务端IP(分多行),设置权重就可以实现负载均衡了

    }


鼎云博客


伪静态:这里使用了https,如果没有开启ssl,需要改成http请求头

location / {

        proxy_pass https://websocket;#代理到上面的地址去,

        proxy_http_version 1.1;

        proxy_set_header Upgrade $http_upgrade;

        proxy_set_header Connection "Upgrade";

}

鼎云博客


鼎云博客
  • 最新评论
  • 总共0条评论