[Catalyst] Lighttpd Proxy Support

Adam Herzog adam at herzogdesigns.com
Tue Oct 10 00:23:19 CEST 2006


I ran into a small problem when using Lighttpd to proxy to my Cat app  
(running under Apache/mod_fastcgi).

Catalyst's proxy support uses the X-Forwarded-For and X-Forwarded- 
Host headers to set the appropriate information about the request.  
Unfortunately, Lighttpd doesn't send X-Forwarded-Host; instead it  
sends X-Host. Lighttpd has had a ticket open asking to have X- 
Forwarded-Host added for quite a while now, so I'm not too hopeful  
that it'll get added any time soon.

So, does it make sense to have Cat check for either of these headers?  
I've included a small patch which adds that support, assuming it's  
sane to do so...

Thanks,
-A

Index: lib/Catalyst/Engine/CGI.pm
===================================================================
--- lib/Catalyst/Engine/CGI.pm  (revision 5057)
+++ lib/Catalyst/Engine/CGI.pm  (working copy)
@@ -128,9 +128,10 @@
              last PROXY_CHECK if $host !~ /localhost|127.0.0.1/;
              last PROXY_CHECK if $c->config->{ignore_frontend_proxy};
          }
-        last PROXY_CHECK unless $ENV{HTTP_X_FORWARDED_HOST};
+        last PROXY_CHECK
+            unless $ENV{HTTP_X_FORWARDED_HOST} || $ENV{HTTP_X_HOST};
-        $host = $ENV{HTTP_X_FORWARDED_HOST};
+        $host = $ENV{HTTP_X_FORWARDED_HOST} || $ENV{HTTP_X_HOST};
          # backend could be on any port, so
          # assume frontend is on the default port





More information about the Catalyst mailing list