用nginx配置wss


nginx配置

nginx配置代码

1
2
3
4
5
6
7
8
9
10
11
 server {
listen 443 ssl;
server_name 域名;
ssl_certificate "ssl证书路径.crt";#如"/etc/nginx/cert/a.crt"
ssl_certificate_key "ssl证书路径.key";#如"/etc/nginx/cert/a.key"
location /ws {
proxy_pass http://127.0.0.1:监听端口;
proxy_set_header Upgrade $http_upgrade;#重要,必须有
proxy_set_header Connection "Upgrade";#重要,必须有
}
}

验证使用

wss://域名/ws