王 静凯,
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’ (I print it in access_log of nginx
to make sure that it is a correct valve.)
I use httpServletRequest.getHeader(“Host”) in java and it can print the
right value too. But as I know the getServerPort should print the number after
‘:’ of ‘Host’ Header.
So I don’t know what’s the wrong.
And today I found another similar situation.
The server has a Internet IP and Tomcat listening 8080 and nginx
listening 81. So there are no port mapping.
At this time getServerPort() still return 80.
Then the port 80 mapping to Internet via 10001.
Use httpServletRequest.getHeader(“Host”) I can get the correct value of Host
header – “InternetIP:10001”.
But httpServletRequest.getServerPort() did not return 10001 and return 80.
How could I solve it?
Btw, to set proxyPort in connector can not take effect. But proxyName work.
Have you read about the RemoteIPValve?
The RemoteIPValve seems to be used for get the real client IP, but I just
need to get the correct port which client use to visit my website.
Forgive my poor English and I hope you can understand what I say. (^-^)
Something does not make sense:
1. You have nginx listening on port 80, proxying to port 100001
2. You have a Tomcat <Connector> on port 8080:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" maxHttpHeaderSize="8192"
maxThreads="4000" minSpareThreads="1000" maxSpareThreads="2000"
enableLookups="false" acceptCount="2000" URIEncoding="UTF-8"
maxPostSize="4194304" />
If Tomcat is listening on port 8080, how is nginx reaching it on port 10001?
-chris
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org