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 127.0.0.1.

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

link|improve this question
feedback

3 Answers

up vote 0 down vote accepted

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

link|improve this answer
feedback

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

link|improve this answer
feedback

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
  </Proxy>

  ProxyPass / http://localhost:8180/
  ProxyPassReverse / http://localhost:8180/
</VirtualHost>

See my stackoverflow answer for more details.

link|improve this answer
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
feedback

Your Answer

 
or
required, but never shown

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