Win a copy of Create an Uber Clone in 7 Days: Build a real world full stack mobile app in Java this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Read Client IP Address behind Proxy  RSS feed

 
Ranch Hand
Posts: 63
  • 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.
 
Ranch Hand
Posts: 212
Eclipse IDE Spring Ubuntu
  • 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
 
Rancher
Posts: 42975
76
  • 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
  • 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.

 
What's wrong? Where are you going? Stop! Read this tiny ad:
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!