[Catalyst] [PATCH] [RFC] Override base URI

Tomas Doran bobtfish at bobtfish.net
Fri Oct 10 08:28:16 BST 2008


On 10 Oct 2008, at 01:33, Andrew Rodland wrote:

> <mst> I've put something like that in a sub prepare before now
> <mst> we should maybe have a config option to override base
> <mst> patches would be welcome :)
>
> Anyway, this is a patch to create a pair of config keys tell
> Engine::CGI "ignore what the server thinks the base path is, and  
> use these
> instead". It's useful in the case that someone has their application
> port-forwarded, load-balanced, proxied, etc. through some sort of  
> device that
> doesn't set X-Forwarded-Host.

Am I correct in thinking that this would be useful in cases other  
than when you're using the CGI engine? Shouldn't this patch be  
generally applicable to all engines? (Patching just the CGI engine  
would make it of somewhat limited use for most people I think)

> How it works: If no config is provided, life continues as it always  
> has. If
> the request is HTTP and $c->config->{override_base_uri} is set, we  
> use that
> as $c->req->base. If the request is HTTPS and
> $c->config->{override_base_uri_secure} is set, we use that as $c- 
> >req->base.
> If the request is HTTPS and override_base_uri_secure isn't set, but
> override_base_uri is, we use override_base_uri and switch its  
> scheme to https
> (hopefully it doesn't have a port).

What I specifically do, which I was hoping this patch would sort out  
for me - is that I unwrap SSL at a proxy layer, and then forward onto  
the application running on a non-secure port..

I have a feeling however that with this patch, even if I specified a  
base_uri that was https://, if the server serving the application was  
http:// then line 95 of your patch would swap the scheme back to http  
for me :(

(My current workaround is to nobble the C::Request::is_secure  
typeglob to sub { 1 } given a certain config key - not the most  
elegant solution)

On that note - the same line (95) - wouldn't you be better swapping  
the scheme by calling a method on the URI object you generate, rather  
than using a regex?

>
> Patch against Catalyst-Runtime/5.80/trunk which I hope is the right  
> thing.
>

Yes :)

Cheers
t0m




More information about the Catalyst mailing list