location /socket.io/ {
proxy_http_version 1.1;
proxy_set_header Upgrade host;
proxy_pass http://127.0.0.1:8089/socket.io/;
}
本地socket访问时,用的是域名 +/socket.io/ ,所以nginx只需要针对socket.io来转发,转发到相应的服务即可,不同于接口
const socket = io("https://9a4474x44.goho.com/", {
query: {},
transports: ["websocket"],
reconnection: true,
autoConnect: true,
})
网友评论