Nginx代理端口重定向忽略端口 [英] Nginx proxy port redirect ignore port

查看:943
本文介绍了Nginx代理端口重定向忽略端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

two nginx  
first nginx:10097->80 port  
second nginx:80 port ->code  

然后,代码获取没有端口的请求URL,但是如果没有重定向,则浏览器上的URL为port 10097,但是如果重定向,则忽略该端口
需要更改nginx代理端口

then,code get the request url no port, but if no redirect, the url on browser has port 10097, but if redirect, the port is ignored
is need change nginx proxy port

推荐答案

说出我的观点: 请求首先到达nginx:将10097端口更改为80端口
到达第二个nginx:80端口是默认端口,将被忽略

say my point: request arrive first nginx: 10097 port change to 80 port
arrive second nginx : 80 port is default port, be ignored

因此,如果要获取端口,可以像这样修改第二个nginx
这意味着将主机和端口传递给代码,然后您就可以在代码中获取端口

so, if you want to get the port ,you can modify second nginx like this
it mean pass host and port to code, then you can get port in the code

answer:proxy_set_header主机$ http_host;

answer : proxy_set_header Host $http_host;

这篇关于Nginx代理端口重定向忽略端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆