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
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
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
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
>> 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
王 静凯,
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’
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