前提概要
- 宝塔新建站点
- 配置SSL 证书 证书配置就是ssl选项填好证书key,pem 即可
- 操作以下
1. 配置文件中添加一下内容
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream wss {
server 111.11.0.111:8986; ## socket的端口地址如:ws://111.11.0.111:8986/bet/?device=h5&EIO=3&transport=websocket
}
2. 伪静态配置
location / {
proxy_pass http://wss; #这里的这个是第一步里面的wss名字
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
校验:
IP替换成域名:
ws://111.11.0.111:8986/bet/?device=h5&EIO=3&transport=websocket
替换:
wss://xxx-xxxx.xxxx6.com/bet/?device=h5&EIO=3&transport=websocket