如果不使用nginx反向代理,直接公網(wǎng)鏈接 wss:// 其中一臺(tái)服務(wù)器沒有問題。
通過內(nèi)網(wǎng)轉(zhuǎn)發(fā)以后
#
upstream apitest_a_wss {
#server 172.24.0.191:2345;
server 172.24.0.193:2345;
}
location /wss/ {
proxy_pass http://apitest_a_wss;
proxy_http_version 1.1;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_read_timeout 3600s;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
使用 wss://xxxx.cn/wss 訪問客戶端會(huì)報(bào)告 101 xxxx 502 bad ....
服務(wù)端上的gatewayworker進(jìn)程會(huì)報(bào)告
SSL handshake error: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:1407609C:SSL routines:SSL23_GET_CLIENT_HELLO:http request
代碼配置 $gateway->lanIp 和 $gateway->registerAddress 都改成了內(nèi)網(wǎng)地址
問題解決了 原來是 proxy_pass http://apitest_a_wss; 改成 proxy_pass https://apitest_a_wss;
就可以了;