workerman正常启动,但是无法链接wss服务,直接访问域名/wss/,正常应该显示websocket,但是目前显示502 bad gateway,有一个很久的帖子类似问题,问题定位在nginx的wss代理配置上,但是试了没有找到问题,服务器也重启过,防火墙也关闭了。
配置了两套服务器,有一台是ok的,另外这台折腾好久还是不行,求大佬支招~
location /wss/
{
proxy_pass http://127.0.0.1:8282;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
rewrite /wss/(.*) /$1 break;
proxy_redirect off;
}
// gateway 进程,这里使用Text协议,可以用telnet测试
$gateway = new Gateway("websocket://0.0.0.0:8282");
// gateway名称,status方便查看
$gateway->name = 'T1111Gateway';
// gateway进程数,一般设置2个就足够
$gateway->count = 2;
// 本机ip,分布式部署时使用内网ip
$gateway->lanIp = '127.0.0.1';
// 内部通讯起始端口,假如$gateway->count=2,起始端口为2900
// 则一般会使用2900 2901 2个端口作为内部通讯端口
$gateway->startPort = 2900;
// 服务注册地址
$gateway->registerAddress = '127.0.0.1:1238';
//心跳间隔
$gateway->pingInterval = 10;
//心跳数据
$gateway->pingData = '{"type":"ping"}';
var socket = new WebSocket("wss://域名/wss/");
php 7.4
workerman 4.1.11
一样的配置,两台服务器,有一台链接不上,求支招~
可能是客户的域名做了cdn
nginx配置
upstream webman {
server 127.0.0.1:8787;
keepalive 10240;
}
server
{
listen 80;
listen 443 ssl http2;
server_name demo.aa.com 74.demo.aa.com;
index index.php index.html index.htm default.php default.htm default.html;
root /www/wwwroot/webman.aa.com/public;
CERT-APPLY-CHECK--START
}
阿里云slb负载配置