location ^~ /websocket {
proxy_redirect off;
proxy_pass http://127.0.0.1:8180; #转发
proxy_set_header Host $host;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr:$remote_port;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; #升级协议头
proxy_set_header Connection upgrade;
}
var uri = "wss://xxx/websocket";
// 打开一个 web socket
var ws = new WebSocket(uri);