Page 1 of 1
How to get real IP Address wen PC is running behind PROXY
Posted: Thu Aug 31, 2006 4:06 am
by poddar_ravi
I was tryin to get the real IP, and used following code
Code: Select all
// This function returns the Client side IP Address
function getIP(){
$ip;
if (getenv("HTTP_CLIENT_IP")) $ip = getenv("HTTP_CLIENT_IP");
else if(getenv("HTTP_X_FORWARDED_FOR")) $ip = getenv("HTTP_X_FORWARDED_FOR");
else if(getenv("REMOTE_ADDR")) $ip = getenv("REMOTE_ADDR");
else $ip = "UNKNOWN";
return $ip;
}
But the thing is My machine is running behind proxy, and it is not giving me client IP, it is always givin me REMOTE_ADD ie 127.0.0.1. Is there any way to get the real IP of my machine, I think There is something wrong in APACHE server. how can i update the env var in apache.
Posted: Thu Aug 31, 2006 4:21 am
by volka
You might change the proxy's configuration and have it forward the ip.
Posted: Thu Aug 31, 2006 4:49 am
by poddar_ravi
I have changed the proxy setting, but still it is not working.
Posted: Thu Aug 31, 2006 4:54 am
by poddar_ravi
In my phpInfo.php page
Apache Environment
REMOTE_ADDR
is 127.0.0.1
but
HTTP_X_FORWARDED_FOR
is not shown there.[/quote]
Posted: Thu Aug 31, 2006 6:29 am
by timvw
You could actually search this forum ... And find out that you won't get any further than 'a best effort' result...
Posted: Thu Aug 31, 2006 6:36 am
by poddar_ravi
can anybody help me to set the environmental variable of APACHE
I have used
Code: Select all
apache_setenv("VAR NAME","VALUE");
But the thing is if i will hardcode this thing, this will not work in the situation where i have to track the user's IP and according to Tracked IP i have to generate reports.
Thanx in Advance
Posted: Thu Aug 31, 2006 7:55 am
by volka
What proxy (for incoming connections) do you use?
What settings did you change to make it append the sender's ip?
Posted: Fri Sep 01, 2006 2:01 am
by poddar_ravi
Hi,
I have changed the manual proxy setting as follows
HTTP Proxy:172.16.16.3
and checked on use this proxy server for all protocols
Now everytime i am gettin the REMOTE_ADDR that is 127.0.0.1
My problem is i am not able to get following variables
1. HTTP_CLIENT_IP
2. HTTP_X_FORWARDED_FOR
Plz help me out to get the value of HTTP_CLIENT_IP and HTTP_X_FORWARDED_FOR variables.
Posted: Fri Sep 01, 2006 6:05 am
by volka
volka wrote:What proxy (for incoming connections) do you use?
Or didn't you change any settings on your server but e.g. for the client-side internet explorer?
Posted: Fri Sep 01, 2006 6:20 am
by poddar_ravi
Yes Mr. Volka
I have not changed anything on SERVER SIDE, i have changed it on the client side only (I am using Mozilla).
Actually i am working in a Software Company, so my PC is behind proxy. Whenever i try to capture my Public IP address, I get only REMOTE_ADDR. I want to capture my Public IP. I am using PHP and apache.
Posted: Fri Sep 01, 2006 6:36 am
by volka
If the proxy does not add the ip the webserver is unable to determine the client's ip.
The connection to the webserver is established by the proxy and therefore remote_addr shows the ip of the proxy.
Posted: Fri Sep 01, 2006 6:44 am
by poddar_ravi
So i cannot get Public IP of any organisation , if the server is configured not to pass related information ie IP.
Posted: Fri Sep 01, 2006 6:49 am
by volka
You can get the ip of their proxy/nat server.
But no, I haven't heard of a browser that sends its own ip as request header. Maybe you can find an addon for mozilla doing that. And maybe then the proxy filters it out again - it really depends on the proxy's configuration

Posted: Mon Sep 04, 2006 3:35 am
by poddar_ravi
Thanx volka.. many many thanx
