Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
It works but a question remains since I can't find examples online of sane people doing it this way. Is this a sound approach? If not, please correct me. If so, maybe the already very excellent mod_perl docs could benefit by adding this information. Thanks for your consideration.
sub My::ProxyRemoteAddr ($) { my $r = shift; return Apache::Constants::OK unless ($r->connection->remote_ip eq "127.0.0.1") and $r->header_in('X-Forwarded-For') and $r->header_in('X-Forwarded-Host'); if (my ($ip) = $r->header_in('X-Forwarded-For') =~ /([^,\s]+)$/) { $r->connection->remote_ip($ip); } if (my ($fh) = $r->header_in('X-Forwarded-Host') =~ /([^,\s]+)$/) { $r->header_in('Host',$fh); } return Apache::Constants::OK; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: mod_perl ProxyPreserveHost Emulation
by perrin (Chancellor) on Jul 22, 2006 at 18:44 UTC | |
by Anonymous Monk on Jul 23, 2006 at 01:39 UTC | |
by perrin (Chancellor) on Jul 23, 2006 at 04:00 UTC |