Some proxies send client IP as "X-FORWARDER-FOR" header.

I am not sure, but probably tomcat uses it instead of REMOTE_ADDR in
getRemoteAddr()? 
That is just a guess.

====================
Kazakevich Ilya,
MCP, SCJP
====================



-----Original Message-----
From: Christopher Schultz [mailto:ch...@christopherschultz.net] 
Sent: Tuesday, March 10, 2009 6:45 PM
To: Tomcat Users List
Subject: Re: request.getRemoteAddr() vs. request.getHeader("REMOTE_ADDR")

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mark,

On 3/6/2009 2:03 PM, Mark Thomas wrote:
> Bing Zheng wrote:
>> The tomcat server (version 5.5.23) is behind a load balancer.  If I 
>> use request.getRemoteAddr(), it returns the load balancer's ip.  If I 
>> use request.getHeader("REMOTE_ADDR"), it returns the correct client 
>> IP address.  Is this a known bug?  Thanks.
> 
> Nope, it is expected behaviour.

Is it? From the javadoc for javax.servlet.ServletRequest:

"Returns the Internet Protocol (IP) address of the client or last proxy that
sent the request. For HTTP servlets, same as the value of the CGI variable
REMOTE_ADDR."

I would think that if
!request.getRemoteAddr().equals(request.getHeader("REMOTE_ADDR")) then
something has gone wrong.

Perhaps a load-balancer doesn't count as a proxy under this definition?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkm2iuIACgkQ9CaO5/Lv0PBEPQCgkT3kiGT9/nUUbmw6B8eTI7Kn
CusAnjzmfCLle3z3ZUgtvN3buVhy0mf+
=B3fe
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to