Apache2::FixRemote - Reset remote IP with contents of X-Forwarded-For header


Apache2-FixRemote documentation Contained in the Apache2-FixRemote distribution.

Index


Code Index:

NAME

Top

Apache2::FixRemote - Reset remote IP with contents of X-Forwarded-For header

VERSION

Top

Version 0.01

SYNOPSIS

Top

    # httpd.conf
    PerlModule Apache2::FixRemote

    PerlPostReadRequestHandler Apache2::FixRemote

    # or alternatively use any handler stage after map-to-storage, such as:
    <Location /foo>
    PerlHeaderParserHandler Apache2::FixRemote
    </Location>

AUTHOR

Top

Dorian Taylor, <dorian at cpan.org>

BUGS

Top

Please report any bugs or feature requests to bug-apache2-fixremote at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Apache2-FixRemote. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

You can find documentation for this module with the perldoc command.

    perldoc Apache2::FixRemote

You can also look for information at:

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/Apache2-FixRemote

* CPAN Ratings

http://cpanratings.perl.org/d/Apache2-FixRemote

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Apache2-FixRemote

* Search CPAN

http://search.cpan.org/dist/Apache2-FixRemote

ACKNOWLEDGEMENTS

Top

COPYRIGHT & LICENSE

Top


Apache2-FixRemote documentation Contained in the Apache2-FixRemote distribution.
package Apache2::FixRemote;

use warnings FATAL => 'all';
use strict;

use Apache2::RequestRec ();
use Apache2::Connection ();
use Apache2::Log        ();

use Apache2::Const -compile => qw(OK);

use APR::Table  ();

our $VERSION = '0.01';

sub handler {
    my $r = shift;
    my $hdr = $r->headers_in->get('X-Forwarded-For');
    if ($hdr and $hdr =~ /^\d+\.\d+\.\d+\.\d+$/) {
        my $old = $r->connection->remote_ip($hdr);
        $r->log->debug("Changed inbound IP from $old to $hdr");
    }
    Apache2::Const::OK;
}

1; # End of Apache2::FixRemote