• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Read Client IP Address behind Proxy

 
Imran Akbar
Ranch Hand
Posts: 63
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 212
Eclipse IDE Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think there's no way to get the client IP who is behind the proxy, not atleast in servlet API
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Imran Akbar
Ranch Hand
Posts: 63
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic