Subject: | Fails with lighttpd as FE proxy |
lighttpd runs www.myapp.org on IP 1.2.3.4 and proxies certain requests
to a Catalyst app that runs with a standalone server on 1.2.3.5.
While everything seem to work with C:E::HTTP, things break with
C:E::HTTP::Prefork. It turns out, that under C:E::HTTP
$c->request->uri returns http://www.myapp.org/, whereas under
C:E::HTTP::Prefork $c->request->uri gives http://1.2.3.5/.
C:E::CGI cares for environment variable HTTP_HOST, to catch the real
local host name. This variable is set from the request header "Host"
in C:E::HTTP, but not in C:E::HTTP::Prefork .
The attached patch fixes this.
It also offers options to drop superuser privileges and to chroot
after listen is set up (haven't tested chroot though).
Subject: | Catalyst-Engine-HTTP-Prefork-0.50.patch |
Index: lib/Catalyst/Engine/HTTP/Prefork.pm
===================================================================
--- lib/Catalyst/Engine/HTTP/Prefork.pm (revision 8804)
+++ lib/Catalyst/Engine/HTTP/Prefork.pm (working copy)
@@ -45,6 +45,9 @@
max_servers => $options->{max_servers} || 50,
max_requests => $options->{max_requests} || 1000,
leave_children_open_on_hup => $options->{restart_graceful} || 0,
+ user => $options->{user} || $ENV{UID},
+ group => $options->{group} || $ENV{GID},
+ defined $options->{'chroot'} ? ('chroot' => $options->{'chroot'}) : (),
);
}
@@ -135,6 +138,10 @@
if $headers->{'X-Forwarded-For'};
$ENV{HTTP_X_FORWARDED_HOST} = $headers->{'X-Forwarded-Host'}
if $headers->{'X-Forwarded-Host'};
+ $ENV{HTTP_X_FORWARDED_PROTO} = $headers->{'X-Forwarded-Proto'}
+ if $headers->{'X-Forwarded-Proto'};
+ $ENV{HTTP_HOST} = $headers->{'Host'}
+ if $headers->{'Host'};
# Determine whether we will keep the connection open after the request
my $connection = $headers->{Connection};