1 package Catalyst::TraitFor::Request::ProxyBase;
4 use namespace::autoclean;
6 our $VERSION = '0.000001';
13 around 'base' => sub {
14 my ($orig, $self, @args) = @_;
16 if (my $base = $self->header('X-Request-Base')) {
17 $base .= '/' unless $base =~ m|/$|;
18 @args = (URI->new($base));
24 around 'secure' => sub {
25 my ($orig, $self, @args) = @_;
26 if (my $base = $self->header('X-Request-Base')) {
27 return URI->new($base)->scheme eq 'http' ? 0 : 1;
38 Catalyst::TraitFor::Request::ProxyBase -
44 use namespace::autoclean;
47 use CatalystX::RoleApplicator;
51 __PACKAGE__->apply_request_class_roles(qw/
52 Catalyst::TraitFor::Request::ProxyBase
59 This module is a L<Moose::Role> which allows you more flexibility in your
60 application's deployment configurations when deployed behind a proxy.
62 The problem is that there is no standard way for a proxy to tell a backend
63 server what the original URI for the request was, or if the request was
64 initially SSL. (Yes, I do know about C<< X-Forwarded-Host >>, but they don't
67 This creates an issue for someone wanting to deploy the same cluster of
68 application servers behind various URI endpoints.
70 Using this module, the request base (C<< $c->req->base >>)
71 is replaced with the contents of the C<< X-Request-Base >> header,
72 which is expected to be a full URI, for example:
76 http://other.example.com:81/foo/bar/yourapp
78 This value will then be used as the base for uris constructed by
81 =head1 REQUIRED METHODS
91 =head1 WRAPPED METHODS
103 Probably. Patches welcome, please fork from:
105 http://github.com/bobtfish/catalyst-traitfor-request-proxybase
107 and send a pull request.
111 Tomas Doran (t0m) C<< <bobtfish@bobtfish.net> >>
115 This module is Copyright (c) 2009 Tomas Doran and is licensed under the same
116 terms as perl itself.