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.
diff --git a/lib/Dancer2/Core/Request.pm b/lib/Dancer2/Core/Request.pm
index c4b5a0eb3..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()
@@ -679,7 +682,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;
}