#!/usr/bin/perl use lib '/srv/www/site.net/www/cgi-bin/admin'; use Links::mod_perl; use Apache2::Connection (); use Apache2::RequestRec (); use APR::Table (); use POSIX; use CGI::Carp; use LWP::Simple; use GeoIP2::WebService::Client; # Automatically fix up the REMOTE_IP environment variable. sub My::ProxyRemoteAddr ($) { # ------------------------------------------------ my $r = shift; my $c = $r->connection(); my $ip = $c->remote_ip; unless ($ip eq '127.0.0.1') { return OK; } # Select last value in the chain -- ip from most recent proxy (to prevent fake ip injection) if (my ($ip) = $r->headers_in->{'HTTP_X_REAL_IP'} =~ /([^,\s]+)$/) { $r->connection->remote_ip($ip); } return OK; } 1;