bbs2web has asked for the wisdom of the Perl Monks concerning the following question:
Current IP Address: 192.0.2.47
ScriptAlias /cgi-bin/ /var/www/perl-cgi/ <Directory /var/www/perl-cgi> SetHandler perl-script PerlHandler ModPerl::Registry AllowOverride None Options +ExecCGI -MultiViews </Directory>
#!/usr/bin/perl -T use Data::Validate::IP qw(is_ip is_public_ip is_loopback_ip); @IPs=''; if (defined $ENV{HTTP_X_FORWARDED_FOR}) { @IPs=split /,/, $ENV{HTTP_X_FORWARDED_FOR}; }; splice @IPs, 0, 0, $ENV{REMOTE_ADDR}; foreach $check (@IPs) { $check =~ s/^\s*(.*?)\s*$/\1/g; if (is_ip($check)) { if (defined $ip) { if (not is_public_ip($check)) { $check = $ip; }; if (is_loopback_ip($check)) { $check = $ip; }; if ($check eq "192.0.2.90") { $check = $ip; }; }; $ip = $check; }; }; print "Content-type: text/html\nCache-Control: max-age=0,no-cache,no-s +tore,post-check=0,pre-check=0\n\n<html><head><title>Current IP Check< +/title></head><body>Current IP Address: $ip</body></html>";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: mod-perl2 re-using $ENV{REMOTE_ADDR}
by Corion (Patriarch) on May 01, 2023 at 07:37 UTC | |
by Bod (Parson) on May 01, 2023 at 22:27 UTC | |
by etj (Priest) on May 02, 2023 at 13:52 UTC | |
by Anonymous Monk on May 03, 2023 at 08:07 UTC | |
by bbs2web (Acolyte) on May 02, 2023 at 19:25 UTC | |
by hv (Prior) on May 02, 2023 at 23:13 UTC | |
by bbs2web (Acolyte) on May 03, 2023 at 19:32 UTC | |
by bbs2web (Acolyte) on May 01, 2023 at 14:07 UTC | |
by Corion (Patriarch) on May 01, 2023 at 16:00 UTC | |
|
Re: mod-perl2 re-using $ENV{REMOTE_ADDR}
by Anonymous Monk on May 01, 2023 at 12:08 UTC |