当我们添加nginx 反向代理长连接后,nginx -t
提示如下
nginx: [emerg] unknown "connection_upgrade" variable
nginx: configuration file /www/server/nginx/conf/nginx.conf test failed
nginx配置文件
location ^~ /
{
proxy_pass https://127.0.0.1:1443/;
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 REMOTE-HOST $remote_addr;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
解决办法
在nginx主配置文件http
标签下添加如下几行
主配置文件yum安装默认路径为/etc/nginx/conf/nginx.conf
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
然后再次nginx -t即解决问题
[…] […]