Catalyst-Runtime

 view release on metacpan or  search on metacpan

lib/Catalyst.pm  view on Meta::CPAN

backend server. An application running on the backend server must deal
with two problems: the remote user always appears to be C<127.0.0.1> and
the server's hostname will appear to be C<localhost> regardless of the
virtual host that the user connected through.

Catalyst will automatically detect this situation when you are running
the frontend and backend servers on the same machine. The following
changes are made to the request.

    $c->req->address is set to the user's real IP address, as read from
    the HTTP X-Forwarded-For header.

    The host value for $c->req->base and $c->req->uri is set to the real
    host, as read from the HTTP X-Forwarded-Host header.

Additionally, you may be running your backend application on an insecure
connection (port 80) while your frontend proxy is running under SSL.  If there
is a discrepancy in the ports, use the HTTP header C<X-Forwarded-Port> to
tell Catalyst what port the frontend listens on.  This will allow all URIs to
be created properly.

t/aggregate/live_engine_request_headers.t  view on Meta::CPAN

use HTTP::Request::Common;

{
    my $creq;

    my $request = GET( 'http://localhost/dump/request',
        'User-Agent'       => 'MyAgen/1.0',
        'X-Whats-Cool'     => 'Catalyst',
        'X-Multiple'       => [ 1 .. 5 ],
        'X-Forwarded-Host' => 'frontend.server.com',
        'X-Forwarded-For'  => '192.168.1.1, 1.2.3.4',
        'X-Forwarded-Port' => 443
    );

    ok( my $response = request($request), 'Request' );
    ok( $response->is_success, 'Response Successful 2xx' );
    is( $response->content_type, 'text/plain', 'Response Content-Type' );
    like( $response->content, qr/^bless\( .* 'Catalyst::Request' \)$/s, 'Content is a serialized Catalyst::Request' );
    ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' ) or fail("Exception deseializing $@ from content " . $response->content);
    isa_ok( $creq, 'Catalyst::Request' );
    ok( $creq->secure, 'Forwarded port sets secure' );



( run in 0.270 second using v1.01-cache-2.11-cpan-26ccb49234f )