我想使用nginx将https://api.example.com/wss/...
之类的网址代理到许多nodejs服务器(socket.io):
upstream websocket {
ip_hash;
server 127.0.0.1:8080;
server 127.0.0.1:8081;
server 127.0.0.1:8082;
}
location /wss/
{
proxy_pass http://websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
在此之后,我想附加我的服务"wss://api.example.com/wss/"
但是当这个请求发送到nodejs服务器时,它不会请求http://127.0.0.1:8080/
而是请求http://127.0.0.1:8080/wss/
,而socket.io将不能在此URI中工作。
如何解决这个问题?
答案 0 :(得分:0)
@Richard Smith在评论中说,它确实有效!
谢谢!