I have Apache with mod_proxy passing requests to Tomcat. The trouble is, when I get client IP address associated with a request in web app hosted on Tomcat, it always returns

Is it possible to have Apache pass the original IP address to Tomcat?


The X-Forwarded-For environment variable should also be set by default with mod_proxy


I'd recommend using mod_jk or mod_proxy_ajp if you're wanting to retain information about the original requests source ip address.


Your configuration should include ProxyPreserveHost On, similar to

<VirtualHost *:80>
  ServerName public.server.name

  ProxyRequests Off
  ProxyPreserveHost On

  <Proxy *>
    Order deny,allow
    Allow from all

  ProxyPass / http://localhost:8180/
  ProxyPassReverse / http://localhost:8180/

See my stackoverflow answer for more details.

  • It did not seem to work with what I needed it for. In the end I decided to go for the X- header. Thank you! – Konrad Garus Apr 12 '10 at 8:36
  • This answer refers to keeping the "public.server.name" on the outgoing request to http://localhost:8180/ not making the client ip valid. – Martin Aug 13 '14 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.