[Catalyst] using frontend proxy with non-/ PATH_INFO

Peter Karman peter at peknet.com
Mon Feb 11 15:37:58 GMT 2008


Here's my setup:

* frontend Apache running mod_proxy, proxying at /myapp
* backend Cat dev server on :3000

I have this config in Apache:

# proxy for MyApp
<Directory /path/to/MyApp/trunk/root/static>
    Order deny,allow
    Allow from all
</Directory>

Alias /static  /path/to/MyApp/trunk/root/static

# neither of these result in PATH_INFO set correctly on backend
RewriteEngine on
RewriteRule      ^/myapp$                      http://localhost:3000/    [P]
RewriteRule      ^/myapp/(.*)$                 http://localhost:3000/$1  [P,L]

# this second config per the Cat cookbook - makes no difference.
#ProxyRequests off
#<Proxy *>
 #Order deny,allow
 #Allow from all
#</Proxy>
#ProxyPass        /myapp                       http://localhost:3000/
ProxyPassReverse /myapp                        http://localhost:3000/


If I am reading Apache docs and Cat code correctly, the issue is that the path 'myapp'
after the / isn't being passed on to the back end. Nor should it be. The problem, though,
is that uri_for() needs to know about it in order to create working URLs.

Here's how I "fixed" the problem, using a local config option called 'prepend_path_info',
but I am hoping someone will show me how my setup is flawed and thus avoid having a hacked
local Cat lib.

--- /usr/local/lib/perl5/site_perl/5.8.8/Catalyst/Engine/CGI.pm Thu Sep 20 04:29:41 2007
+++ lib/Catalyst/Engine/CGI.pm  Mon Feb 11 09:27:07 2008
@@ -137,6 +137,10 @@
     }

     # set the request URI
+    if ( $c->config->{prepend_path_info} ) {
+        $base_path = $c->config->{prepend_path_info} . $base_path;
+    }
+
     my $path = $base_path . ( $ENV{PATH_INFO} || '' );
     $path =~ s{^/+}{};



-- 
Peter Karman  .  peter at peknet.com  .  http://peknet.com/




More information about the Catalyst mailing list