I'm not really interested in this patch for a few reasons:
1) The functionality is available via a custom pattern
2) X-Forwarded-For (IIRC) can be multi-valued (comma seperated via multiple
proxies)
3) X-Forwarded - This can break existing implementations for clients which
are sending X-Forwarded-For (but we wish to ignore)
-Tim
Phil Shaw wrote:
While I'm subscribed to this list I would like to submit this method
for logging forwarded IP addresses when Tomcat is behind a proxy.
Replace the simple request.getRemoteAddr(); call in the invoke method
of AccessLogValve with getClientIp(ServletRequest).
Hope this may be useful. If you need a more formal assignment to
Apache, please let me know.
Best regards,
Phil
/**
* Get a forwarded client IP address if available.
* @param The servlet request object.
* @return The HTTP <code>X-Forwarded-For</code> header value if
present,
* or the default remote address if not.
*/
private final String getClientIp(final ServletRequest request) {
try {
HttpServletRequest httpRequest = (HttpServletRequest) request;
String forwardedIp = httpRequest.getHeader("X-Forwarded-For");
if (forwardedIp != null) {
return forwardedIp;
}
else {
return request.getRemoteAddr();
}
}
catch (ClassCastException cce) {
return request.getRemoteAddr();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]