Hello,
Getting the IP address of the client can be tricky because each traversed proxy and load balancer adds an IP address to the multi valued, comma delimited, value of the X-Forwarded-For header (see
Wikipedia X-Forwarded-For page). Moreover, web client can tweak the X-Forwarded-For with tools like Firefox
Modify Headers or
X-Forwarded-For Spoofer add-ons.
The forthcoming version of Apache Httpd will offer a secure mechanism to handle X-Forwarded-For with
mod_remoteip.
Here are a Tomcat valve
RemoteIpValve and a servlet filter
XForwardedFilter to repectively integrate the X-Forwarded-For and X-Forwarded-Proto (http or https) headers at the Tomcat and WAR levels.
Thanks to these valve and filter, the actual client ip and the incoming protocol (http/https) will be available in Tomcat logs (if you use the valve) and in the servlet API (
request.getRemoteAddr(), request.getRemoteHost(), request.isSecure(), request.getScheme() and request.getServerPort()).
The Tomcat RemoteIpValve has been proposed to the Tomcat Project as
Bug 47330 - proposal : port of mod_remoteip in Tomcat as RemoteIpValve.
Hope thise helps,
Cyrille