location ^~/prod-api/ {
proxy_pass http://$api_host:$api_port;
......
}
异常情况:
连接 http://$api_host:8877/ws/ 就会异常
server {
listen 443 ssl;
set $api_host api;
..........
location /ws/ {
proxy_pass http://$api_host:8877/ws/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_connect_timeout 90s;
proxy_send_timeout 120s;
proxy_read_timeout 120s;
send_timeout 120s;
}
}
正常情况:
设置 http://api:8877/ws/ 正常
server {
listen 443 ssl;
set $api_host api;
..........
location /ws/ {
proxy_pass http://api:8877/ws/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_connect_timeout 90s;
proxy_send_timeout 120s;
proxy_read_timeout 120s;
send_timeout 120s;
}
}
在 nginx 容器内两种设置的抓包截图:
https://imgur.com/a/XzyNFQ6
搞不清楚是什么原因导致这种情况,为什么不能这样配。想请教下大家