我想使用nginx将网络套接字请求转发到微服务。
我击中https://some-host/download-zip-service/downloadFile
通过这种方式,呼叫将在 download-zip-service 上登陆,并且 downloadFile API会获得呼叫。
在 downloadFile 中,我正在使用套接字将请求转发到微服务
但是当我尝试从 download-zip-service 调用套接字API时
我做了类似var socket = io('https://some-host/download-zip-service/');
通话直接打入
wss://some-host/socket.io/?EIO=3&transport=websocket&sid=12345678
代替https://some-host/download-zip-service/socket.io/?EIO=3&transport=websocket&sid=12345678
作为一个原因,我明确为download-zip-service添加了根/
路径。
下面是我的NGINX.conf文件
worker_processes 4;
events { worker_connections 1024; }
http {
sendfile on;
upstream download-zip-service {
server xx.xx.xx.xx:9012;
}
server {
listen 8765;
#Changed for implementing WEB Socket
location / {
proxy_pass http://download-zip-service/;
proxy_redirect off;
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Host $server_name;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
#new property added
proxy_request_buffering off;
proxy_buffering off;
}
location /download-zip-service/ {
proxy_pass http://download-zip-service/;
proxy_redirect off;
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Host $server_name;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
#socket timeout setting added
fastcgi_read_timeout 7200s;
send_timeout 7200s;
proxy_connect_timeout 7200s;
proxy_send_timeout 7200s;
proxy_read_timeout 7200s;
#new property added
proxy_request_buffering off;
proxy_buffering off;
}
}
}
我要删除下载zip服务的根/
路径。
它应该与/download-zip-service/
一起使用
请让我知道我在哪里做错了