Catalyst::TraitFor::Request::ProxyBase - Replace request base with value passed by HTTP proxy
package MyApp; use Moose; use namespace::autoclean; use Catalyst; use CatalystX::RoleApplicator; extends 'Catalyst'; __PACKAGE__->apply_request_class_roles(qw/ Catalyst::TraitFor::Request::ProxyBase /); __PACKAGE__->setup;
This module is a Moose::Role which allows you more flexibility in your application's deployment configurations when deployed behind a proxy.
The problem is that there is no standard way for a proxy to tell a backend server what the original URI for the request was, or if the request was initially SSL. (Yes, I do know about X-Forwarded-Host, but they don't do enough)
X-Forwarded-Host
This creates an issue for someone wanting to deploy the same cluster of application servers behind various URI endpoints.
Using this module, the request base ($c->req->base) is replaced with the contents of the X-Request-Base header, which is expected to be a full URI, for example:
$c->req->base
X-Request-Base
http://example.com https://example.com http://other.example.com:81/foo/bar/yourapp
This value will then be used as the base for uris constructed by $c->uri_for.
$c->uri_for
Probably. Patches welcome, please fork from:
http://github.com/bobtfish/catalyst-traitfor-request-proxybase
and send a pull request.
Tomas Doran (t0m) <bobtfish@bobtfish.net>
<bobtfish@bobtfish.net>
This module is Copyright (c) 2009 Tomas Doran and is licensed under the same terms as perl itself.
To install Catalyst::TraitFor::Request::ProxyBase, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::TraitFor::Request::ProxyBase
CPAN shell
perl -MCPAN -e shell install Catalyst::TraitFor::Request::ProxyBase
For more information on module installation, please visit the detailed CPAN module installation guide.