tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Johan van den Berg <>
Subject Patch to override request.getRemoteAddr if behind a reverse proxy
Date Sat, 15 Jul 2006 11:38:47 GMT

We needed to patch Tomcat for our site that has a Tomcat
behind Apache (mod_jk), that sits behind a reverse proxy load balancer.
The idea is basically to not use the TCP endpoint of Apache (which will
always point to the reverse proxy) to give the caller of
request.getRemoteAddr a valid IP, but rather retrieve it from a
configurable request header. In our case, we have hacked the Pound
loadbalancer to forward a request header called X-Pounded-For with each
request, and the value of this header is then used (if available) to
return the *real client IP to the caller of request.getRemoteAddr or

Extract from server.xml:

<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" proxyRemoteAddrHeader="X-Pounded-For"
enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />

Let me know if it is of any use to anyone else!


Johan van den Berg
Technical Webmaster
University of South Africa

Cel: +27 73 201 3520
Tel: +27 12 429 2371

Registered Linux user number 390606

View raw message