Nginx代理端口重定向忽略端口 [英] Nginx proxy port redirect ignore port
问题描述
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屋!