NAME
Catalyst::TraitFor::Request::ProxyBase - Replace request base with value passed by HTTP proxy
SYNOPSIS
package
MyApp;
use
Moose;
use
namespace::autoclean;
use
Catalyst;
__PACKAGE__->apply_request_class_roles(
qw/
Catalyst::TraitFor::Request::ProxyBase
/
);
__PACKAGE__->setup;
DESCRIPTION
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)
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:
This value will then be used as the base for uris constructed by $c->uri_for
.
In addition the request uri ($c->req->uri
) will reflect the scheme and path specifed in the header.
REQUIRED METHODS
WRAPPED METHODS
APACHE SETUP
On the frontend Proxy Apache, you would want to enable a Virtualhost config somewhat like this. The backend apache config stays unchanged.
<Virtualhost *:80>
ProxyRequests Off
<Location /preview>
# You must have mod_headers enabled for that
# RequestHeader set X-Request-Base /preview
RequestHeader set X-Request-Base http://www.example.com/preview
</Location>
</Virtualhost>
BUGS
Probably. Patches welcome, please fork from:
and send a pull request.
AUTHORS
Tomas Doran (t0m) <bobtfish@bobtfish.net>
CONTRIBUTORS
Klaus Ita (koki) <klaus@worstofall.com>
COPYRIGHT
This module is Copyright (c) 2009 Tomas Doran and is licensed under the same terms as perl itself.