Hello, I have a web application load balanced in an intranet and I need to get the hostname of the client from the request (for audit purposes).
I have verified that the load balancer is adding the header "x-forwarded-for" and I get the correct client IP with the HttpServletRequest method "getRemoteAddr()". Also, I have enabled the lookups setting to true "enableLookups" and if I connect from a client to the server without passing through the load balancer, the hostname of the client is correctly obtained with "getRemoteHost()". However when I send a request from a client passing through the load-balancer the hostname is not resolved, I get only the IP when using the method "getRemoteHost()". I have been looking at the source code for Tomcat 7 and Tomcat 8 and I see that in both classes that seems to handle the x-forwarded-for header, the hostname is never obtained from IP: - org.apache.catalina.valves.RemoteIpValve - org.apache.catalina.filters.RemoteIpFilter For example in RemoteIpValve ( https://github.com/apache/tomcat/blob/trunk/java/org/apache/catalina/valves/RemoteIpValve.java), we have: *[...]* if (remoteIp != null) { request.setRemoteAddr(remoteIp); request.setRemoteHost(remoteIp); [...] And the remote host is never resolved. Of course I can put a filter in my web application to do search the hostname from the remote IP using "java.net.InetAddress" for example but I was wondering if a Tomcat native solution exists. If not, is there any particular reason for this, or is it because no body has required that feature. Thanks, Yann Nicolas