[dev] SERVER_NAME:SERVER_PORT and UseCanonicalName in Apache conflict

Barry Flanagan barryf-lists@online.ie
Mon, 12 Nov 2001 16:34:01 +0000


On Monday 12 November 2001 15:28, you wrote:
> On Mon, Nov 12, 2001 at 03:13:13PM +0000, Barry Flanagan wrote:
> > In line 280 of lib/Horde.php, you are specifically building the redirect
> > URLs based on the reported SERVER_NAME and SERVER_PORT variables.
> >
> > This causes a problem in a set up like ours where we use front-end load
> > balancers which map (say) port 80 for a specific external IP to an
> > arbitrary internal host/port of our choosing.
> >
> > As it happens, our IMP installation is running on ports 81 and 444.
> > Apache handles redirects perfectly by using 'UseCanonicalName Off', thus
> > building URLs based on the client-supplied HTTP_HOST variable alone (i.e.
> > 'http://mail.online.ie'). However, Horde RC1 is sending back
> > 'http://mail.online.ie:81' which does not exist in the world outside our
> > internal network.
> >
> > Is there any real need for Horde to be building these redirect URLs as
> > opposed to the web server? I can see this affecting Virtual Host setups
> > where the SERVER_NAME (which is server wide) is NOT where the redirect
> > should be pointed, which would more likely want to be HOST_NAME.
>
> We need the ability to generate absolute URLs for things like the
> Location: headers were use for redirection.
>
> Aside from not generating URLs in PHP land, what would you
> suggest for fixing this?  Is there another environmental variable
> we should be using?


Well, is it not the case that all you really need to do is generate the 
relative URL, the client will figure out the URL from the host and protocol 
that the link originated from. For example:

If a URL 'http://www.somehost.com/redirect.php' returns a redirect of 
'/login.php' (with no host:port specified), the client will resolve that 
differently depending on what the original request was. If the original 
request was to https://www.somehost.com/redirect.php, the redirect will 
resolve as 'https://www.somehost.com/login.php' ; if you had requested 
https://www.somehost.com:443/redirect.php the redirect would resolve to 
'https://www.somehost.com:443/login.php' ; same with any addressing such as 
'http://ww.somehost.com:80/', etc.

I just can't see why Horde/PHP needs to get involved at this level at all. 
Where is it that you would require to send an ABSOLUTE Location: header - the 
only time AFAIK that an absolute Location: is needed is if you explicitly 
need to change the host or port that you want to redirect to.

Regards,

-Barry