我有以下(简化)设置。
我从客户端致电http://somedomain.com/my.jsp
通过代理将其转发到apache 1或apache 2
在我的jsp中我想要server1-domain.com
或server2-domain.com
而不是somedomain.com
request.getServerName()
在标题中为somedomain.com
提供了“主机”参数somedomain.com
看似相似但恰恰相反:tomcat-getheaderhost-vs-getservername
但我无法转换'ProxyPreserveHost',因为我不是群集中唯一的...最佳解决方案是不必更改任何东西到domaincontroller / loadbalancer / apaches
我可以通过JSP方法/ param获取它吗?
答案 0 :(得分:0)
我最终使用了这个:
String hostname = InetAddress.getLocalHost().getHostName();