aspose file tools*
The moose likes JSP and the fly likes Read Client IP Address behind Proxy Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Read Client IP Address behind Proxy" Watch "Read Client IP Address behind Proxy" New topic
Author

Read Client IP Address behind Proxy

Imran Akbar
Ranch Hand

Joined: May 06, 2010
Posts: 63
Hi Ranch,

we have a requirement to fetch IP address of client machine and display it on the user page, for that i used a JSP page which does like below :



This works fine, when the system is connected directly to internet, but when its connected thru a Proxy server we receive only its proxy server IP address instead of the Client Local IP.

Is there any way we can retrieve the Client IP running behind proxy?

Thanks in advance.
sudhir nim
Ranch Hand

Joined: Aug 29, 2007
Posts: 212

I think there's no way to get the client IP who is behind the proxy, not atleast in servlet API


[Servlet tutorial] [Servlet 3.0 Cook Book]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
Is this a client-side proxy, or a server-side proxy? If the former, then that information is most likely not available. If the latter, then there may be a custom request header (something like "X-Forwarded-For") into which the proxy puts the IP address. That's what an Apache would do that sits in front of a Tomcat.


Ping & DNS - my free Android networking tools app
Imran Akbar
Ranch Hand

Joined: May 06, 2010
Posts: 63
Its a client side Proxy.

I appended the code



and i was able to fetch the IP of the client local machine behind proxy.

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Read Client IP Address behind Proxy