From 848eaeffe24db24f5e19cbbd99cc691a660b90a6 Mon Sep 17 00:00:00 2001 From: Fayland Lam Date: Thu, 24 Apr 2014 16:34:11 +0800 Subject: [PATCH 1/3] put HTTP_REQUEST_BASE support back from Dancer 1 --- lib/Dancer2/Core/Request.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Dancer2/Core/Request.pm b/lib/Dancer2/Core/Request.pm index c4b5a0eb3..f5a8c3d1e 100644 --- a/lib/Dancer2/Core/Request.pm +++ b/lib/Dancer2/Core/Request.pm @@ -679,7 +679,13 @@ sub _common_uri { my $uri = URI->new; $uri->scheme($scheme); $uri->authority( $host || "$server:$port" ); - $uri->path( $path || '/' ); + if (setting('behind_proxy')) { + my $request_base = $self->env->{REQUEST_BASE} || $self->env->{HTTP_REQUEST_BASE} || ''; + $uri->path($request_base . $path || '/'); + } + else { + $uri->path($path || '/'); + } return $uri; } From 9e60df67016bea3c06178ea50a44054291ac98a3 Mon Sep 17 00:00:00 2001 From: Fayland Lam Date: Thu, 24 Apr 2014 16:43:33 +0800 Subject: [PATCH 2/3] sub request_base --- lib/Dancer2/Core/Request.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Dancer2/Core/Request.pm b/lib/Dancer2/Core/Request.pm index f5a8c3d1e..beca7f193 100644 --- a/lib/Dancer2/Core/Request.pm +++ b/lib/Dancer2/Core/Request.pm @@ -73,6 +73,8 @@ supported: =item C +=item C + =item C =item C @@ -415,6 +417,7 @@ sub protocol { $_[0]->env->{SERVER_PROTOCOL} } sub port { $_[0]->env->{SERVER_PORT} } sub request_uri { $_[0]->env->{REQUEST_URI} } sub user { $_[0]->env->{REMOTE_USER} } +sub request_base { $_[0]->env->{REQUEST_BASE} || $_[0]->env->{HTTP_REQUEST_BASE} } sub script_name { $_[0]->env->{SCRIPT_NAME} } =method scheme() From f5c739bdca2aaf602cc7e6759b5a3572374d58fc Mon Sep 17 00:00:00 2001 From: Fayland Lam Date: Thu, 24 Apr 2014 16:49:29 +0800 Subject: [PATCH 3/3] update cookbook --- lib/Dancer2/Cookbook.pod | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/Dancer2/Cookbook.pod b/lib/Dancer2/Cookbook.pod index 2e5e84503..c33af7015 100644 --- a/lib/Dancer2/Cookbook.pod +++ b/lib/Dancer2/Cookbook.pod @@ -1288,6 +1288,12 @@ under a specified dir: ProxyPass /mywebapp/ http://localhost:3000/ ProxyPassReverse /mywebapp/ http://localhost:3000/ + + RequestHeader set Request-Base /mywebapp + + +HTTP header C is taken into account by Dancer, only when +C setting is set to true. It is important for you to note that the Apache2 modules C and C must be enabled.