Hi,
I would like to retrieve the IP address of the remote hosts connected to an intranet application. When I use $_SERVER['REMOTE_ADDR'] variable, this contains the proxy server IP address. What is the correct technique to retrieve ip address of a host PC behind a proxy server in PHP? :confused:
Thanks
How to get the address of remote host behind proxy server
Started by rhossis, May 28 2011 05:15 AM
4 replies to this topic
#1
Posted 28 May 2011 - 05:15 AM
|
|
|
#2
Posted 28 May 2011 - 08:23 AM
You can't, without getting a result that is meaningless to you. Your only way to send messages back is via the proxy server IP address. You could use javascript to request the IP address from the client, but then it will be sending you a LAN address that you can't communicate with either.
The real question is: what are you trying to accomplish, and why is the proxy server IP address a problem?
The real question is: what are you trying to accomplish, and why is the proxy server IP address a problem?
#3
Posted 28 May 2011 - 09:40 AM
Hi, the main reason is not for communication purposes but for audit but it is that the user logging shows the proxy server IP whenever it is logging access information, I would prefer it stored the IP address of the host (for audit purposes).
#4
Posted 28 May 2011 - 01:11 PM
A non-standard standard of external proxies (i.e, squid which has implemented such) are to send X_FORWARDED_FOR (XFF) headers so that the host can differentiate between the external IP addresses of the proxy stream, although this is client set and should only be trusted if you know the client (i.e. in your department.)
Try the following: $_SERVER['HTTP_X_FORWARDED_FOR']
I would note if is compliant to this, it should give you a comma delimited list of IP addresses (i.e. client, proxy1, proxy2, load balancer 3...)
Try the following: $_SERVER['HTTP_X_FORWARDED_FOR']
I would note if is compliant to this, it should give you a comma delimited list of IP addresses (i.e. client, proxy1, proxy2, load balancer 3...)
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
#5
Posted 28 May 2011 - 11:28 PM
Thanks. I will try that out at the office and give you the feedback. We are using Apache 2.2.17.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









