This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can I turn on X-Forwarded-For in local Tomcat 6?