How do I get the IP address of the real client, not the IP address of a proxy server?

JIA Java Italian Association

If the client is using a proxy server, the real request to your servlets arrives fromt the proxy, and so you get the proxy's IP address.

Some proxies will complete the request with an header like "X-Forwarded" or "X-Forward-IP", or something similar. That header will contain the 'real' IP address.

Be aware that fortunately there are a lot of anonymous proxy servers and they do not pass any additional header (and sometimes they do not appear as proxy).

["Fortunately" for an anonymous user, but unfortunately for a server admin. Ah, the constant struggle between privacy and features... :-) -Alex]