[Catalyst] Setting $c->req->{base}

Andy Grundman andy at hybridized.org
Mon Sep 19 23:09:39 CEST 2005


Alessio Bragadini wrote:
> Hi all,
> I am stumbling on a problem with my Catalyst setup, and maybe I am
> overlooking something obvious. I have a dual-server setup using Apache,
> a frontend server on port 80 with mod_proxy/mod_rewrite and a backend
> server on port 8080 with mod_perl. In the production environment they
> will also be on different machines (this is a fairly common setup).
> 
> However, $c->req->{base} gets set automatically in
> Catalyst::Engine::HTTP::Base::prepare_path to
> http://backend.machine:8080/ instead of the path I want to show to the
> users. This ends up in templates if I use [% base %] but unfortunately
> also in cookies and self-referencing URLs.
> 
> I don't see any obvious way to fix this, and especially I cannot easily
> figure out at which point of the request cycle it would be better to
> act. Any help, or directions for a possible plugin, would be much
> appreciated.
> 

I think the solution is to check the variable HTTP_X_FORWARDED_HOST (or 
maybe _SERVER) which on my double-Apache setup appears to contain the 
frontend hostname.

This could be done in a plugin but is probably better handled in the 
engine layer.

-Andy



More information about the Catalyst mailing list