首页 新闻 会员 周边 捐助

nginx 重定向后端口丢失,配置如下

0
悬赏园豆:20 [已关闭问题] 关闭于 2022-03-29 14:00

http {
include mime.types;
default_type application/octet-stream;

upstream tomcat_cluster {
server 10.10.50.157:8081 weight=3;
server 10.10.50.156:8081 weight=2;
}

sendfile        on;
keepalive_timeout  65;

server {

   		listen 9527;
	server_name 10.10.50.81;
	
	proxy_set_header Host $host;  
    	proxy_set_header X-Real-IP $remote_addr;  
    	proxy_set_header X-Forwarded-HOST $host:$9527;  # 关键需要在此处添加端口号变量,或者直接使用端口号9527
    	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

	absolute_redirect off;
	proxy_redirect   off;
	location / {
	proxy_pass http://tomcat_cluster;
	root html;
	index index.html index.htm;
	}


    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

}

}

请诸位大神解惑

凉凉90的主页 凉凉90 | 菜鸟二级 | 园豆:204
提问于:2022-03-29 13:39

配置改成如下:location / {
proxy_pass http://tomcat_cluster;
proxy_set_header Host $host:$server_port;
}

凉凉90 2年前
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册