http :: get system ip behind the proxy
env variable REMOTE_ADDR is used to get the ip address of the requesting system in http protocol. But if the end host sending its request through a proxy, then REMOTE_ADDR will have the ip of the proxy.
In that case the env variable HTTP_X_FORWARDED_FOR holds the ip of the host, for which the proxy is working for.
A simple cgi script to use it.
[ creates a access log file of the visiting ips(deeper than proxy ip) ]
fopen(FH, “>>access.log”);
if( $ENV{’HTTP_X_FORWARDED_FOR’} ){
print FH “$ENV{’HTTP_X_FORWARDED_FOR’} ( $ENV{’REMOTE_ADDR’} )”;
}else{
print FH “$ENV{’REMOTE_ADDR’}”;
}
close FH;
In squid, one can choose not to forward the ip of the host it is working for by setting the tag forwarded_for as off






August 27th, 2005 at 1:28 pm
Re:
Your blogs are really awesome. This blog solved my big problem.
Thanks,