Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

3 Answers 3

up vote 3 down vote accepted

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

share|improve this answer

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

share|improve this answer

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.

share|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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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