httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sorin Manolache <sor...@gmail.com>
Subject Re: How to determine the "right" vhost in name based vhosting
Date Thu, 19 Sep 2013 19:09:53 GMT
On 2013-09-19 16:39, Christoph Gröver wrote:
>
> Hello,
>
> We usually use name based virtualhosts with something like the following
> configuration:
>
> NameVirtualHost  IP:80
>
> <VirtualHost IP:80>
>    ServerName main.domain.tld
>    ServerAlias alias.domain.tld
>
>    ..
> </VirtualHost>
>
> <VirtualHost IP:80>
>    ServerName www.domain.tld
>    ServerAlias alt.domain.tld
>    ..
> </VirtualHost>

I've tested this setup in 2.4.6 and r->server->server_hostname contains 
what you want.

Regards,
Sorin

>
> Now I'm looking for a function which reliable returns the
> host main.domain.tld if the first vhost is used (even if
> it is used as alias.domain.tld) and returns www.domain.tld
> if the second one is used (even if under the name alt.domain.tld).
>
>
> I know of two ways to do this:
>
> 1. ap_get_server_name
>
>   This returns the right hostname if "UseCanonicalName" is set.
>   But returns just the Host:-Header if it is off - which is the default.
>
> 2. server_rec structure
>
>   The element server->server_hostname always returns the first vhost
>   available for an ip address. So even if I use www.domain.tld it returns
>   main.domain.tld
>
> So the first option depends on "UseCanonicalName", the second does
> something else - which is not what I want.
>
> Any other ways of doing this?
> Or is there just the solution to force "UseCanonicalName" to "on"
> and otherwise it won't work.
>
> Can anybody enlighten me as to how this should be done?
>
> Thank you, Greetings
>


Mime
View raw message