In a situation where Apache is sitting behind a reverse proxy (such as Squid), the cgi environment variable REMOTE_ADDR gets the address of the proxy rather tha
REMOTE_ADDR
You can use mod_rpaf for that. http://stderr.net/apache/rpaf/