Reputation: 6420
I have following (simplified) setup.
From the client I call http://somedomain.com/my.jsp
via the proxy it's forwarded to apache 1 or apache 2
In my jsp I want the server1-domain.com
or server2-domain.com
and not somedomain.com
request.getServerName()
gives me somedomain.com
in the header the 'Host' param is also somedomain.com
It seems similar but just the opposite to: tomcat-getheaderhost-vs-getservername
But I cannot turn of 'ProxyPreserveHost' as I am not the only one on the cluster... Optimal solution is not having to change anything to the domaincontroller/loadbalancer/apaches
Can I get it via just a JSP method/param?
Upvotes: 2
Views: 6937
Reputation: 6420
I ended up using this:
String hostname = InetAddress.getLocalHost().getHostName();
Upvotes: 2