Nginx tomcat集群 转发后端口丢失

场景: 阿里云主机 docker 搭建nginx集群,访问项目端口丢失

配置如下:

丢失的可能原因:

proxy_set_header Host设置不对,修改如下: 

proxy_set_header Host $http_host;

proxy_set_header Host 可以设置有如下几种:

proxy_set_header Host $proxy_host; //proxy_pass后面的值
proxy_set_header Host $http_host;  //浏览器请求的 IP 和端口
proxy_set_header Host $host;       //proxy_pass后面的host的值,没有端口
proxy_set_header Host $host:$proxy_port;

详细参考:

http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_set_header

https://www.jianshu.com/p/7a8a7eb3707a

 
 转自 :https://blog.csdn.net/lipei1220/article/details/107514417
原文地址:https://www.cnblogs.com/javalinux/p/14317549.html