Result:
found 114 distributions and 273 files matching your query ! ( run in 1.168 )


Mojolicious-Plugin-ForwardedFor

 view release on metacpan or  search on metacpan

lib/Mojolicious/Plugin/ForwardedFor.pm  view on Meta::CPAN

  die "Invalid reverse proxy 'levels' for ForwardedFor: $err" if defined $err;

  $app->helper(forwarded_for => sub {
    my $c = shift;
    return $c->tx->original_remote_address unless $levels > 0;
    my @addresses = split /\s*,\s*/, trim($c->tx->req->headers->header('X-Forwarded-For') // '');
    return $addresses[-$levels] // $addresses[0] // $c->tx->original_remote_address;
  });
}

1;

=head1 NAME

Mojolicious::Plugin::ForwardedFor - Retrieve the remote address from X-Forwarded-For

=head1 SYNOPSIS

  use Mojolicious::Lite;
  plugin ForwardedFor => {levels => 2}; # number of reverse proxies you control

lib/Mojolicious/Plugin/ForwardedFor.pm  view on Meta::CPAN

L<Mojolicious> supports deployment via a
L<reverse proxy|Mojolicious::Guides::Cookbook/"Reverse proxy"> setup by
specifying the L<proxy|Mojo::Server::Hypnotoad/"proxy"> configuration option
for Hypnotoad, or the C<MOJO_REVERSE_PROXY> environment variable. However,
L<Mojo::Transaction/"remote_address"> will in this case only return the most
recent address from the C<X-Forwarded-For> header, as it cannot automatically
determine how many remote addresses correspond to proxies.

L<Mojolicious::Plugin::ForwardedFor> can be configured with the number of
reverse proxy L</"levels"> that you control, and provides a L</"forwarded_for">
helper method that will return the remote address at that level. It is
important to set L</"levels"> no higher than the number of proxies that will
have appended addresses to the C<X-Forwarded-For> header, as the original
requests can pass anything as the initial value of the header, and thus spoof
additional proxy levels.

Since Mojolicious 8.72, you can configure
L<Mojo::Server::Hypnotoad/"trusted_proxies"> as a more reliable alternative to

lib/Mojolicious/Plugin/ForwardedFor.pm  view on Meta::CPAN


=head2 forwarded_for

  my $remote_addr = $c->forwarded_for;

Returns the least recently appended remote address from the C<X-Forwarded-For>
header, while skipping no more than the configured number of reverse proxy
L</"levels">. Returns the originating address of the current request if
configured for 0 reverse proxy levels, or if no addresses have been appended to
the header.

lib/Mojolicious/Plugin/ForwardedFor.pm  view on Meta::CPAN


=over 4

=item levels

Number of remote proxy levels to allow for when parsing C<X-Forwarded-For>.
Defaults to the value of the C<MOJO_REVERSE_PROXY> environment variable, or 1.

=back

=head1 BUGS

 view all matches for this distribution


Mojolicious-Plugin-Geolocation-MMDB

 view release on metacpan or  search on metacpan

t/basic.t  view on Meta::CPAN


local $ENV{MOJO_REVERSE_PROXY} = 1;

my $t = Test::Mojo->new;

$t->get_ok('/', {'X-Forwarded-For' => '176.9.54.163'})
    ->status_is(200)
    ->json_is('/city/names/en'    => 'Falkenstein')
    ->json_is('/country/names/en' => 'Germany');

$t->get_ok('/176.9.54.163')

 view all matches for this distribution


Mojolicious-Plugin-OpenTelemetry

 view release on metacpan or  search on metacpan

lib/Mojolicious/Plugin/OpenTelemetry.pod  view on Meta::CPAN


=item C<client.address>

Set to the
L<remote address of the transaction|Mojo::Transaction/remote_address>. This
will respect the value set in the C<X-Forwarded-For> header, if any.

=item C<client.port>

Set to the L<remote port of the transaction|Mojo::Transaction/remote_port>.

 view all matches for this distribution


Mojolicious-Plugin-PlackMiddleware

 view release on metacpan or  search on metacpan

xt/compat/lite_app.t  view on Meta::CPAN

# Root with format
$t->get_ok('/.html')->status_is(200)
  ->header_is(Server => 'Mojolicious (Perl)')
  ->content_is("/root.html\n/root.html\n/root.html\n/root.html\n/root.html\n");

# Reverse proxy with "X-Forwarded-For"
{
  local $ENV{MOJO_REVERSE_PROXY} = 1;
  $t->ua->server->restart;
  $t->get_ok('/0' => {'X-Forwarded-For' => '192.0.2.2, 192.0.2.1'})
    ->status_is(200)->header_unlike('X-Original' => qr/192\.0\.2\.1/)
    ->content_like(qr!http://127\.0\.0\.1:\d+/0-192\.0\.2\.1-0$!);
}

# Reverse proxy with "X-Forwarded-Proto"

xt/compat/lite_app.t  view on Meta::CPAN

  $t->get_ok('/0' => {'X-Forwarded-Proto' => 'https'})->status_is(200)
    ->content_like(qr!^https://127\.0\.0\.1:\d+/0-!)->content_like(qr/-0$/)
    ->content_unlike(qr!-192\.0\.2\.1-0$!);
}

# "X-Forwarded-For"
$t->ua->server->restart;
$t->get_ok('/0' => {'X-Forwarded-For' => '192.0.2.2, 192.0.2.1'})
  ->status_is(200)->content_like(qr!^http://127\.0\.0\.1:\d+/0-!)
  ->content_like(qr/-0$/)->content_unlike(qr!-192\.0\.2\.1-0$!);

# "X-Forwarded-Proto"
$t->get_ok('/0' => {'X-Forwarded-Proto' => 'https'})->status_is(200)

 view all matches for this distribution


Mojolicious-Plugin-RemoteAddr

 view release on metacpan or  search on metacpan

lib/Mojolicious/Plugin/RemoteAddr.pm  view on Meta::CPAN

        foreach my $place ( @{ $conf->{order} } ) {
            if ( $place eq 'x-real-ip' ) {
                my $ip = $c->req->headers->header('X-Real-IP');
                return $ip if $ip;
            } elsif ( $place eq 'x-forwarded-for' ) {
                my $ip = $c->req->headers->header('X-Forwarded-For');
                return $ip if $ip;
            } elsif ( $place eq 'tx' ) {
                my $ip = $c->tx->remote_address;
                return $ip if $ip;
            }

lib/Mojolicious/Plugin/RemoteAddr.pm  view on Meta::CPAN

  my $ip = $self->remote_addr;

=head1 DESCRIPTION

L<Mojolicious::Plugin::RemoteAddr> adds simple helper "remote_addr" which returns an ip address of a remote host, It tries getting remote ip in different ways.
Firstly, it takes 'X-Real-IP' header. Secondly, it takes 'X-Forwarded-For' header. If they are empty it takes the ip from current request transaction.

=head1 CONFIG

=head2 order

lib/Mojolicious/Plugin/RemoteAddr.pm  view on Meta::CPAN


'X-Real-IP' request header

=item 'x-forwarded-for'

'X-Forwarded-For' request header

=item 'tx'

current request transaction

 view all matches for this distribution


Mojolicious-Plugin-SecureOnly

 view release on metacpan or  search on metacpan

lib/Mojolicious/Plugin/SecureOnly.pm  view on Meta::CPAN

  });
}

sub detect_proxy {
  my $c = shift;
  return $c->tx->req->headers->header('X-Forwarded-For') || $c->tx->req->headers->header('X-Forwarded-Proto')
}

1;

__END__

 view all matches for this distribution


Mojolicious-Plugin-TrustedProxy

 view release on metacpan or  search on metacpan

t/01_ip_headers.t  view on Meta::CPAN

  ->status_is(200)->content_is('1.1.1.1', sprintf(
    '[%s.%d] Assert from header X-Real-IP => 1.1.1.1 that tx->remote_address == 1.1.1.1',
    $TEST, $tid)
  );

# Header: [default] X-Forwarded-For (single)
$tid++;
$tc += 3;
$t->get_ok('/ip' => {'X-Forwarded-For' => '1.1.1.1'})
  ->status_is(200)->content_is('1.1.1.1', sprintf(
    '[%s.%d] Assert from header X-Forwarded-For => 1.1.1.1 that tx->remote_address == 1.1.1.1',
    $TEST, $tid)
  );

# Header: [default] X-Forwarded-For (multiple)
$tid++;
$tc += 3;
$t->get_ok('/ip' => {'X-Forwarded-For' => '1.1.1.1 , 2.2.2.2,3.3.3.3'})
  ->status_is(200)->content_is('1.1.1.1', sprintf(
    '[%s.%d] Assert from header X-Forwarded-For => "1.1.1.1 , 2.2.2.2,3.3.3.3" that tx->remote_address == 1.1.1.1',
    $TEST, $tid)
  );

# Check IPv6 support
$tid++;
$tc += 3;
$t->get_ok('/ip' => {'X-Forwarded-For' => 'fc01:c0ff:ee::'})
  ->status_is(200)->content_is('fc01:c0ff:ee::', sprintf(
    '[%s.%d] Assert from header X-Forwarded-For => fc01:c0ff:ee:: that tx->remote_address == fc01:c0ff:ee::',
    $TEST, $tid)
  );

# Check bad IP value
$tid++;
$tc += 3;
$t->get_ok('/ip' => {'X-Forwarded-For' => '123.456.789.000'})
  ->status_is(200)->content_is('127.0.0.1', sprintf(
    '[%s.%d] Assert from header X-Forwarded-For => 123.456.789.000 that tx->remote_address == 127.0.0.1',
    $TEST, $tid)
  );

# Check remote_proxy_address
$tid++;

 view all matches for this distribution


Net-API-Telegram

 view release on metacpan or  search on metacpan

lib/Net/API/Telegram.pm  view on Meta::CPAN

				my $req;
				my $ip_check = 0;
				REQUEST: while( $req = $client->get_request ) 
				{
					my $remote_addr;
					if( $req->header( 'X-Forwarded-For' ) )
					{
						$remote_addr = Net::IP->new( $req->header( 'X-Forwarded-For' ) );
					}
					else
					{
						$remote_addr = Net::IP->new( Socket::inet_ntoa( $client->peeraddr ) );
					}

 view all matches for this distribution


Net-FullAuto

 view release on metacpan or  search on metacpan

lib/Net/FullAuto/ISets/Local/EmailServer_is.pm  view on Meta::CPAN

       '%NL%        }'.
       '%NL%'.
       '%NL%        location /rspamd {'.
       '%NL%            proxy_pass http://127.0.0.1:11334/;'.
       '%NL%            proxy_set_header Host $host;'.
       '%NL%            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;'.
       '%NL%        }'.
       '%NL%'.
       '%NL%        location ~ ^/(README.md|INSTALL|LICENSE|CHANGELOG|UPGRADING)$ {'.
       '%NL%            deny all;'.
       '%NL%        }'.

 view all matches for this distribution


Net-WURFL-ScientiaMobile

 view release on metacpan or  search on metacpan

lib/Net/WURFL/ScientiaMobile.pm  view on Meta::CPAN

    
    # Add HTTP Headers to pending request
    $headers{'User-Agent'} = $self->_user_agent;
    $headers{'X-Cloud-Client'} = __PACKAGE__ . " $VERSION";
    
    # Add X-Forwarded-For
    {
        my $ip = $self->_http_request->{REMOTE_ADDR};
        my $fwd = $self->_http_request->{HTTP_X_FORWARDED_FOR};
        if ($ip) {
            $headers{'X-Forwarded-For'} = "$ip" . ($fwd ? ", $fwd" : "");
        }
    }
    
    # We use 'X-Accept' so it doesn't stomp on our deflate/gzip header
    $headers{'X-Accept'} = $self->_http_request->{HTTP_ACCEPT} if $self->_http_request->{HTTP_ACCEPT};

 view all matches for this distribution


Net-WebSocket-EVx

 view release on metacpan or  search on metacpan

lib/Net/WebSocket/EVx.pod  view on Meta::CPAN

        listen 127.0.0.1:5000;
        location / {
          proxy_pass http://app;
          proxy_ignore_client_abort on;
          proxy_set_header Host $http_host;
          proxy_set_header X-Forwarded-For $http_x_forwarded_for;
          proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection $connection_upgrade;
        }
      }

 view all matches for this distribution


Nginx-Perl

 view release on metacpan or  search on metacpan

CHANGES  view on Meta::CPAN

Changes with nginx 1.5.2                                         02 Jul 2013

    *) Feature: now several "error_log" directives can be used.

    *) Bugfix: the $r->header_in() embedded perl method did not return value
       of the "Cookie" and "X-Forwarded-For" request header lines; the bug
       had appeared in 1.3.14.

    *) Bugfix: in the ngx_http_spdy_module.
       Thanks to Jim Radford.

CHANGES  view on Meta::CPAN

    *) Bugfix: new sessions were not always stored if the "ssl_session_cache
       shared" directive was used and there was no free space in shared
       memory.
       Thanks to Piotr Sikora.

    *) Bugfix: multiple X-Forwarded-For headers were handled incorrectly.
       Thanks to Neal Poole for sponsoring this work.

    *) Bugfix: in the ngx_http_mp4_module.
       Thanks to Gernot Vormayr.

CHANGES  view on Meta::CPAN

    *) Change: the "proxy_set_x_real_ip" is canceled and must be replaced
       with the "proxy_set_header X-Real-IP $remote_addr" directive.

    *) Change: the "proxy_add_x_forwarded_for" is canceled and must be
       replaced with
       the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for"
       directive.

    *) Change: the "proxy_set_x_url" is canceled and must be replaced with
       the "proxy_set_header X-URL http://$host:$server_port$request_uri"
       directive.

 view all matches for this distribution


OpenInteract

 view release on metacpan or  search on metacpan

OpenInteract/ApacheStartup.pm  view on Meta::CPAN


use constant DEBUG => 0;

$OpenInteract::ApacheStartup::VERSION   = sprintf("%d.%02d", q$Revision: 1.26 $ =~ /(\d+)\.(\d+)/);

# Create a handler to put the X-Forwarded-For header into the IP
# address -- thanks Stas! (perl.apache.org/guide/)

my $PROXY_SUB = <<'PROXY';

  sub OpenInteract::ProxyRemoteAddr ($) {
    my ( $r ) = @_;
    return unless ( ref $r );
    if ( my ( $ip ) = $r->header_in( 'X-Forwarded-For' ) =~ /([^,\s]+)$/ ) {
      $r->connection->remote_ip( $ip );
    }
    return Apache::Constants::OK;
  }
PROXY

 view all matches for this distribution


PAGI

 view release on metacpan or  search on metacpan

lib/PAGI/App/Proxy.pm  view on Meta::CPAN

            push @headers, "$h->[0]: $h->[1]";
        }
        push @headers, "Host: $host:$port";

        # Add X-Forwarded headers
        push @headers, "X-Forwarded-For: $scope->{client}[0]" if $scope->{client};
        push @headers, "X-Forwarded-Proto: $scope->{scheme}" if $scope->{scheme};

        # Add extra headers
        for my $name (keys %$extra_headers) {
            push @headers, "$name: $extra_headers->{$name}";

 view all matches for this distribution


POE-Component-Server-Bayeux

 view release on metacpan or  search on metacpan

lib/POE/Component/Server/Bayeux.pm  view on Meta::CPAN

            $content = <$in>;
        }
        close $in;
        $response->content($content);

        my $ip = $request->header('X-Forwarded-For') || $request->{connection}{remote_ip};
        $heap->{logger}->info(sprintf 'Serving %s %s %s', $ip, $uri->path, $response->content_type);
    }
    else {
        $response->code(RC_NOT_FOUND);
        $response->content("Path '".$uri->path."' not found");

lib/POE/Component/Server/Bayeux.pm  view on Meta::CPAN

sub handle_cometd {
    my ($kernel, $heap, $request, $response) = @_[KERNEL, HEAP, ARG0, ARG1];

    # Deny based upon ClientMaxConnections restrictions

    my $ip = $request->header('X-Forwarded-For') || $request->{connection}{remote_ip};
    if (! $ip) {
        $ip = '0.0.0.0';
        $heap->{logger}->error("No IP found for cometd request");
    }

 view all matches for this distribution


POE-XUL

 view release on metacpan or  search on metacpan

lib/POE/Component/XUL.pm  view on Meta::CPAN

    local $self->{logging}->{app} = $app;

    my $conn = $req->connection;
    my @log;
    push @log, ($conn ? $conn->remote_ip : '0.0.0.0');
    if( $log[-1] eq '127.0.0.1' and $req->header( 'X-Forwarded-For' ) ) {
        $log[-1] = $req->header( 'X-Forwarded-For' );
    }
    # push @log, ($self->{preforked} ? $$ : '-');
    push @log, $$, '-';

    

 view all matches for this distribution


Parse-NetApp-ASUP

 view release on metacpan or  search on metacpan

examples/7.2.3/asup02.txt  view on Meta::CPAN

From UNKNOWN (HTTP POST) Sat Mar 17 23:53:05 2012 (177682)
Received: from UNKNOWN via NGZXTAAPP02-PRD.CORP.NETAPP.COM (HTTP POST) for spiderX.corp.netapp.com; 17 Mar 2012 23:53:05 PDT
X-Forwarded-For: 160.109.21.1
X-Netapp-asup-version: 2
X-Netapp-asup-content: complete
X-Netapp-asup-subject: System Notification from stmgr01 (WEEKLY_LOG) INFO
X-Netapp-asup-system-id: 0101177530
X-Netapp-asup-os-version: NetApp Release 7.2.3: Thu Jul  5 09:51:46 PDT 2007

 view all matches for this distribution


Paws

 view release on metacpan or  search on metacpan

lib/Paws/ELBv2/SourceIpConditionConfig.pm  view on Meta::CPAN

One or more source IP addresses, in CIDR format. You can use both IPv4
and IPv6 addresses. Wildcards are not supported.

If you specify multiple addresses, the condition is satisfied if the
source IP address of the request matches one of the CIDR blocks. This
condition is not satisfied by the addresses in the X-Forwarded-For
header. To search for addresses in the X-Forwarded-For header, use
HttpHeaderConditionConfig.



=head1 SEE ALSO

 view all matches for this distribution


Pcore-Nginx

 view release on metacpan or  search on metacpan

share/tmpl/nginx/host_conf.nginx  view on Meta::CPAN

        proxy_read_timeout 60s;

        proxy_set_header Host $host;
        proxy_set_header X-Accel-Support 1;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        # keepalive & websocket
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;

 view all matches for this distribution


Pcore-Service-Nginx

 view release on metacpan or  search on metacpan

share/tmpl/nginx/host_conf.nginx  view on Meta::CPAN

        proxy_read_timeout 60s;

        proxy_set_header Host $host;
        proxy_set_header X-Accel-Support 1;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        # keepalive & websocket
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;

 view all matches for this distribution


Pcore

 view release on metacpan or  search on metacpan

share/tmpl/nginx/vhost-load-balancer.nginx  view on Meta::CPAN

        proxy_read_timeout 60s;

        proxy_set_header Host $host;
        proxy_set_header X-Accel-Support 1;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        # keepalive & websocket
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;

 view all matches for this distribution


Perlbal-Plugin-ForwardedFor

 view release on metacpan or  search on metacpan

lib/Perlbal/Plugin/ForwardedFor.pm  view on Meta::CPAN

} 

sub rewrite_header {
    my ( $svc, $target_header ) = @_;
    my $headers     = $svc->{'req_headers'};
    my $header_name = 'X-Forwarded-For';
    my $forwarded   = $headers->header($header_name);
    my $DELIMITER   = q{, };
    my $EMPTY       = q{};

    my @ips = split /$DELIMITER/, $forwarded;

lib/Perlbal/Plugin/ForwardedFor.pm  view on Meta::CPAN


__END__

=head1 NAME

Perlbal::Plugin::ForwardedFor - Rename the X-Forwarded-For header in Perlbal

=head1 VERSION

Version 0.02

=head1 SYNOPSIS

This plugin changes the header Perlbal will use to delcare itself as a proxy.

Usually Perlbal will - perl RFC - add itself to X-Forwarded-For, but this
plugins allows you to change that to any header you want, so you could differ
Perlbal from other possible proxies the user might have.

In your Perlbal configuration:

lib/Perlbal/Plugin/ForwardedFor.pm  view on Meta::CPAN


=head2 rewrite_header

The function that is called as the callback.

Rewrites the I<X-Forwarded-For> to whatever header name you specified in the
configuration file.

=head1 AUTHOR

Sawyer X, C<< <xsawyerx at cpan.org> >>

 view all matches for this distribution


Perlbal

 view release on metacpan or  search on metacpan

lib/Perlbal/BackendHTTP.pm  view on Meta::CPAN

    if ($svc->trusted_ip($client_ip)) {
        # yes, we trust our upstream, so just append our client's IP
        # to the existing list of forwarded IPs, if we're a blind proxy
        # then don't append our IP to the end of the list.
        unless ($svc->{blind_proxy}) {
            my @ips = split /,\s*/, ($hds->header("X-Forwarded-For") || '');
            $hds->header("X-Forwarded-For", join ", ", @ips, $client_ip);
        }
    } else {
        # no, don't trust upstream (untrusted client), so remove all their
        # forwarding headers and tag their IP as the x-forwarded-for
        $hds->header("X-Forwarded-For", $client_ip);
        $hds->header("X-Host", undef);
        $hds->header("X-Forwarded-Host", undef);
    }

    $self->tcp_cork(1);

 view all matches for this distribution


Plack-App-Prerender

 view release on metacpan or  search on metacpan

lib/Plack/App/Prerender.pm  view on Meta::CPAN

    unless ($self->request) {
        $self->request(
            {
                'User-Agent' => 'X-Forwarded-User-Agent',
                ( map { $_ => $_ } qw/
                  X-Forwarded-For
                  X-Forwarded-Host
                  X-Forwarded-Port
                  X-Forwarded-Proto
                  /
                ),

lib/Plack/App/Prerender.pm  view on Meta::CPAN


It will default to the following headers:

=over

=item C<X-Forwarded-For>

=item C<X-Forwarded-Host>

=item C<X-Forwarded-Port>

 view all matches for this distribution


Plack-App-Proxy-WebSocket

 view release on metacpan or  search on metacpan

lib/Plack/App/Proxy/WebSocket.pm  view on Meta::CPAN

    my $headers = $self->SUPER::build_headers_from_env($env, $req);

    # if x-forwarded-for already existed, append the remote address; the super
    # method fails to maintain a list of multiple proxies
    if (my $forwarded_for = $env->{HTTP_X_FORWARDED_FOR}) {
        $headers->{'X-Forwarded-For'} = "$forwarded_for, $env->{REMOTE_ADDR}";
    }

    # the super method depends on the user agent to add the host header if it
    # is missing, so set the host if it needs to be set
    if ($uri && !$headers->{'Host'}) {

lib/Plack/App/Proxy/WebSocket.pm  view on Meta::CPAN

=head1 METHODS

=head2 build_headers_from_env

Supplement the headers-building logic from L<Plack::App::Proxy> to maintain
the complete list of proxies in C<X-Forwarded-For> and to set the following
headers if they are not already set: C<X-Forwarded-Proto> to the value of
C<psgi.url_scheme>, C<X-Real-IP> to the value of C<REMOTE_ADDR>, and C<Host>
to the host and port number of a URI (if given).

This is called internally.

 view all matches for this distribution


Plack-App-Proxy

 view release on metacpan or  search on metacpan

lib/Plack/App/Proxy.pm  view on Meta::CPAN


sub build_headers_from_env {
    my($self, $env, $req) = @_;

    my $headers = $req->headers->clone;
    $headers->header("X-Forwarded-For" => $env->{REMOTE_ADDR});
    $headers->remove_header("Host") unless $self->preserve_host_header;
    $self->filter_headers( $headers );

    +{ map {$_ => scalar $headers->header($_) } $headers->header_field_names };
}

 view all matches for this distribution


Plack-Middleware-GeoIP

 view release on metacpan or  search on metacpan

lib/Plack/Middleware/GeoIP.pm  view on Meta::CPAN


=head1 SYNOPSIS

  # with Plack::Middleware::RealIP
  enable 'Plack::Middleware::RealIP',
      header => 'X-Forwarded-For',
      trusted_proxy => [ qw(192.168.1.0/24 192.168.2.1) ];
  enable 'Plack::Middleware::GeoIP',
      GeoIPDBFile => [ '/path/to/GeoIP.dat', '/path/to/GeoIPCity.dat' ],
      GeoIPEnableUTF8 => 1;

 view all matches for this distribution


Plack-Middleware-Greylist

 view release on metacpan or  search on metacpan

t/01-greylist.t  view on Meta::CPAN

            };
            return $app->($env);
        };
    };

    # Trust the "X-Forwarded-For" header
    enable "ReverseProxy";

    enable "Greylist",
      default_rate => 5,
      retry_after  => 120,

t/01-greylist.t  view on Meta::CPAN

    test_psgi
      app    => $handler,
      client => sub($cb) {

        for my $suff ( 1 .. 5 ) {
            my $req = HEAD "/", "X-Forwarded-For" => "172.16.0.${suff}";
            my $res = $cb->($req);
            is $res->code, HTTP_OK, "request ok";
        }

        my $req = HEAD "/", "X-Forwarded-For" => "172.16.0.10";
        my $res = $cb->($req);
        is $res->code, HTTP_TOO_MANY_REQUESTS, "too many requests";

        is \@logs, [ { level => "warn", message => "Rate limiting 172.16.0.10 after 6/5 for 172.16.0.0/24" } ], "logs";

t/01-greylist.t  view on Meta::CPAN

    test_psgi
      app    => $handler,
      client => sub($cb) {

        for my $suff ( 1 .. 5 ) {
            my $req = HEAD "/", "X-Forwarded-For" => "13.96.0.${suff}";
            my $res = $cb->($req);
            is $res->code, HTTP_OK, "request ok";
        }

        my $req = HEAD "/", "X-Forwarded-For" => "13.104.0.1";
        my $res = $cb->($req);
        is $res->code, HTTP_TOO_MANY_REQUESTS, "too many requests";

        is \@logs, [ { level => "warn", message => "Rate limiting 13.104.0.1 after 6/5 for 13.104.0.0/14" } ], "logs";

t/01-greylist.t  view on Meta::CPAN


    test_psgi
      app    => $handler,
      client => sub($cb) {

        my $req = HEAD "/", "X-Forwarded-For" => "172.16.1.1";

        for ( 1 .. 6 ) {
            my $res = $cb->($req);
            is $res->code, HTTP_OK, "request ok";
        }

t/01-greylist.t  view on Meta::CPAN


    test_psgi
      app    => $handler,
      client => sub($cb) {

        my $req = HEAD "/", "X-Forwarded-For" => "107.20.17.110";

        for ( 1 .. 3 ) {
            my $res = $cb->($req);
            is $res->code, HTTP_OK, "request ok";
        }

t/01-greylist.t  view on Meta::CPAN

        }

        is \@logs, [ { level => "warn", message => "Rate limiting 107.20.17.110 after 4/3 for 107.20.0.0/14" } ], "logs";

        {
            my $res = $cb->( HEAD "/", "X-Forwarded-For" => "107.20.17.111" );
            is $res->code, HTTP_OK, "request ok (different IP in same block)";
        }

      };

t/01-greylist.t  view on Meta::CPAN


    test_psgi
      app    => $handler,
      client => sub($cb) {

        my $req = HEAD "/", "X-Forwarded-For" => "13.67.224.13";

        for ( 1 .. 2 ) {
            my $res = $cb->($req);
            is $res->code, HTTP_FORBIDDEN, "forbidden";
        }

t/01-greylist.t  view on Meta::CPAN


    test_psgi
      app    => $handler,
      client => sub($cb) {

        my $req = HEAD "/", "X-Forwarded-For" => "66.249.64.1";

        for ( 1 .. 10 ) {
            my $res = $cb->($req);
            is $res->code, HTTP_OK, "request ok";
        }

 view all matches for this distribution


Plack-Middleware-LemonLDAP-BasicAuth

 view release on metacpan or  search on metacpan

lib/Plack/Middleware/LemonLDAP/BasicAuth.pm  view on Meta::CPAN


    my $xheader = $env->{'X_FORWARDED_FOR'};
    $xheader .= ", " if ($xheader);
    $xheader .= $env->{REMOTE_ADDR};

    my $soap_headers = HTTP::Headers->new( "X-Forwarded-For" => $xheader );

    my $soap = SOAP::Lite->proxy(
        $self->portal || '',
        default_headers => $soap_headers,
    )->uri('urn:Lemonldap::NG::Common::CGI::SOAPService');

 view all matches for this distribution


Plack

 view release on metacpan or  search on metacpan

t/Plack-Middleware/access_log.t  view on Meta::CPAN

    };
};

{
    my $req = GET "http://example.com/";
    $req->header("Host" => "example.com", "X-Forwarded-For" => "192.0.2.1");

    my $fmt = "%P %{Host}i %p %{X-Forwarded-For}i %{Content-Type}o %{%m %y}t %v";
    $test->($fmt)->($req);
    chomp $log;
    my $month_year = POSIX::strftime('%m %y', localtime);
    is $log, "$$ example.com 80 192.0.2.1 text/plain [$month_year] example.com";
}

 view all matches for this distribution


( run in 1.168 second using v1.01-cache-2.11-cpan-39bf76dae61 )