logo       

Getting client IP when using proxy: msg#00177

java.jetty.support

Subject: Getting client IP when using proxy

Our application (a web-based massive multiplayer game) runs JBoss 3.0.1 with
Jetty 4.1.0. Recently, we added an Apache server configured as a proxy
between the clients and Jetty. The problem we have now is that whenever a
servlet tries to get the client's IP address through
ServletRequest.getRemoteAddr() it gets the IP of the proxy. This is not a
huge problem, since Apache can be configured to add a HTTP header called
X-Forwarded-For with the client's IP address. Still though, we get only the
proxy's IP address in the request log.

My question is whether there's an alternative to
ServletRequest.getRemoteAddr() that returns the IP of the actual client, or
whether it would be feasible to let Jetty return the content of
X-Forwarded-For (if it exists) from getRemoteAddr(). All of this without
breaking the servlet spec too much of course. :-)

This is kind of a philosophical question, since there are not that many
calls to getRemoteAddr() in our code, so it wouldn't be a problem to change
it, and as we already have our own logging class, logging the correct IP
addresses in the request log isn't an issue. I guess I just had to ventilate
this. :-)


Martin Vilcans
Developer, Jadestone Group AB
http://www.jadestone.se


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/CBxunD/vN2EAA/xGHJAA/CefplB/TM
---------------------------------------------------------------------~->

For the latest information about Jetty, please see http://jetty.mortbay.org



Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/





<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise