map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# 有关说明参阅:nginx教程:map $http_upgrade $connection_upgrade升级连接配置解读-CSDN博客
server {
listen 8002;
server_name localhost;
location / {
proxy_pass http://192.168.122.18:8002;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
#proxy_set_header Connection keep-alive;
proxy_set_header Host $host:$server_port;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}