Subject: | Catalyst::Engine::CGI and HTTP don't honour X-Forwarded-Host |
When using the dev server (CGI/HTTP engine) X-Forwarded-Host ports are
not honoured.
Attached is a patch to fix.
Subject: | catalyst_runtime_cgi_port_forwarding.patch |
diff -ur Catalyst-Runtime-5.7007.orig/lib/Catalyst/Engine/CGI.pm Catalyst-Runtime-5.7007/lib/Catalyst/Engine/CGI.pm
--- Catalyst-Runtime-5.7007.orig/lib/Catalyst/Engine/CGI.pm 2007-03-13 09:28:23.000000000 +0000
+++ Catalyst-Runtime-5.7007/lib/Catalyst/Engine/CGI.pm 2007-08-03 17:03:27.000000000 +0100
@@ -132,9 +132,14 @@
$host = $ENV{HTTP_X_FORWARDED_HOST};
- # backend could be on any port, so
- # assume frontend is on the default port
- $port = $c->request->secure ? 443 : 80;
+ if ( $host =~ /^(.+):(\d+)$/ ) {
+ $host = $1;
+ $port = $2;
+ } else {
+ # backend could be on any port, so
+ # assume frontend is on the default port
+ $port = $c->request->secure ? 443 : 80;
+ }
}
# set the base URI
diff -ur Catalyst-Runtime-5.7007.orig/lib/Catalyst/Engine/HTTP.pm Catalyst-Runtime-5.7007/lib/Catalyst/Engine/HTTP.pm
--- Catalyst-Runtime-5.7007.orig/lib/Catalyst/Engine/HTTP.pm 2007-03-13 13:17:56.000000000 +0000
+++ Catalyst-Runtime-5.7007/lib/Catalyst/Engine/HTTP.pm 2007-05-15 12:37:14.000000000 +0100
@@ -277,6 +277,10 @@
if ( my $error = delete $self->{_write_error} ) {
DEBUG && warn "Write error: $error\n";
close Remote;
+ if(defined $pid) {
+ $daemon->close;
+ exit;
+ }
next LISTEN;
}