nginx配置:
map $http_upgrade $connection_upgrade {
default keep-alive;
'websocket' upgrade;
}
set_real_ip_from 127.0.0.1;
set_real_ip_from 192.168.203.1;
real_ip_recursive on;
real_ip_header X-Forwarded-For;
....
location /
{
gzip off;
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;#this line
#proxy_set_header Connection $connection_upgrade;
}
“proxy_set_header升级”将导致转发请求丢失“X-Real-IP”标头,如果注释掉此行它将起作用。nginx版本:1.20.0 谢谢!