wood burning stoves 2.0*
The moose likes Tomcat and the fly likes Can I turn on X-Forwarded-For in local Tomcat 6? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Can I turn on X-Forwarded-For in local Tomcat 6?" Watch "Can I turn on X-Forwarded-For in local Tomcat 6?" New topic
Author

Can I turn on X-Forwarded-For in local Tomcat 6?

Christopher Swearingen
Greenhorn

Joined: May 02, 2012
Posts: 8
I need to be able to read request.getHeader("X-Forwarded-For") for web app I'm working on. Currently the Tomcat 6 server, running on my local machine, reports null. Is it possible to turn this on in Tomcat 6? How? I'm a total newb at administering Tomcat/Apache.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
This needs to be turned on in Apache, not in Tomcat (which merely reports the value sent by Apache).
Christopher Swearingen
Greenhorn

Joined: May 02, 2012
Posts: 8
Tim Moores wrote:This needs to be turned on in Apache, not in Tomcat (which merely reports the value sent by Apache).


OK.... so is this possible on a local version of Tomcat/Apache? We're using RTC which is just Eclipse with IBMisms. Again I'm a newb to Apache so I don't even know where to begin. If it's possible I'm assuming a configuration file somewhere? My setup is at C:\tomcat\ and there is a \conf directory that contains a server.xml. Right area?
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
No, those files/directories are all for the Tomcat. This header needs to be enabled in the Apache httpd web server that's in front of the Tomcat. At least that's how I understood your setup to be - is that correct?

If there is no Apache httpd, then you don't need to use this header - the remote IP you get from the HttpServletRequest should be the correct one.
 
jQuery in Action, 2nd edition
 
subject: Can I turn on X-Forwarded-For in local Tomcat 6?
 
Similar Threads
Read Client IP Address behind Proxy
request.getRemoteAddr() 127.0.0.1 ?
behaviour of doStartTag of TagSupport
tomcat 6.0 v. 5.5?
How to get Client's IP address in Servlet