回复: getServerPort always return 80

2022-01-24 Thread 王 静凯
Hi, I have found what cause this problem after compile a tomcat with some logs. In RemoteIpValve.java’s method ‘invoke’, it check if protocolHeader is null. My nginx send a header ‘X-Forwarded-Proto http’ to tomcat. So it call setPorts method and use the default port (80) of http

Re: 回复: getServerPort always return 80

2022-01-06 Thread Hua Zhang
Hi Wang, I hope that this link will help you to solve the problem: https://stackoverflow.com/questions/19751313/forward-request-headers-from-nginx-proxy-server You may check the tomcat access log to see what kind of traffic it received from nginx to confirm that your issue is related to nginx

回复: 回复: getServerPort always return 80

2022-01-06 Thread 王 静凯
Hi Hua, You are right, when tomcat listening port 80, then getServerPort return 10001. So how to resolve this problem when I use nginx as a reverse-proxy? I write in nginx config file: “proxy_set_header Host$http_host;” or “proxy_set_header Host

Re: 回复: getServerPort always return 80

2022-01-06 Thread Hua Zhang
Hi Wang, A second application (nginx) is involved here. The problem can be related to nginx, nginx received a http traffic on 10001 in access log does not mean that if forwards exactly the same original http request. Probably some configuration needs to be changed there. You should take a look in

回复: 回复: getServerPort always return 80

2022-01-05 Thread 王 静凯
>> Hi chris, >> >>> I use httpServletRequest.getServerPort() to get the port in my jsp. >>> When the tomcat listen 8080 and nginx listen 80. >>> Nginx has set ‘proxy_set_header Host $http_host’. >> >>> What is the value of $http_host? >> >> The $http_host is ‘externalIP:10001’ (I print it

Re: 回复: getServerPort always return 80

2022-01-05 Thread Christopher Schultz
王 静凯, On 1/5/22 01:55, 王 静凯 wrote: Hi chris, I use httpServletRequest.getServerPort() to get the port in my jsp. When the tomcat listen 8080 and nginx listen 80. Nginx has set ‘proxy_set_header Host $http_host’. What is the value of $http_host? The $http_host is ‘externalIP:10001’

回复: getServerPort always return 80

2022-01-04 Thread 王 静凯
Hi chris, > I use httpServletRequest.getServerPort() to get the port in my jsp. > When the tomcat listen 8080 and nginx listen 80. > Nginx has set ‘proxy_set_header Host $http_host’. > What is the value of $http_host? The $http_host is ‘externalIP:10001’ (I print it in access_log of nginx