You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Kees Hoekzema <ke...@tweakers.net> on 2002/08/12 04:05:13 UTC

VirtualHosts and ServerName/Alias

Hey all,

I have a few questions concerning virtualhosts.
First, is it allowed to only use an ServerAlias is the <VirtualHost>?
Example:

<VirtualHost *>
    DocumentRoot /www/htdocs/tweakers
    ServerAlias *.tweakers.net
</VirtualHost>

So no "ServerName *.tweakers.net" here, instead of it a "ServerAlias
*.tweakers.net"
This is because i'm loadbalancing my site over up to 6 webservers, and i
want the name of that server to show up in the 40x, 50x and /server-status
pages. (so it says "realservername.tweakers.net" instead of
"virtualhostservername.tweakers.net").

Second, when I have an configuration like:

ServerName test.tweakers.net
DocumentRoot /www/htdocs
# vhost1
<VirtualHost *>
    DocumentRoot /www/htdocs/tweakers.www
    ServerAlias www.tweakers.net
</VirtualHost>
# vhost 2
<VirtualHost *>
    DocumentRoot /www/htdocs/tweakers
    ServerAlias *.tweakers.net
</VirtualHost>

and a request for test.tweakers.net comes in, wich docroot will get used?
three posibilities ofcourse: /www/htdocs, /www/htdocs/tweakers or
/www/htdocs/tweakers.www. And why?

tia,
Kees Hoekzema


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: VirtualHosts and ServerName/Alias

Posted by Joshua Slive <jo...@slive.ca>.
Kees Hoekzema wrote:

> So no "ServerName *.tweakers.net" here, instead of it a "ServerAlias
> *.tweakers.net"
> This is because i'm loadbalancing my site over up to 6 webservers, and i
> want the name of that server to show up in the 40x, 50x and /server-status
> pages. (so it says "realservername.tweakers.net" instead of
> "virtualhostservername.tweakers.net").

Use:
UseCanonicalName off
to get this to work.  But you should also have a ServerName in there, 
just for completeness if nothing else.

> 
> Second, when I have an configuration like:
> 
> ServerName test.tweakers.net
> DocumentRoot /www/htdocs
> # vhost1
> <VirtualHost *>
>     DocumentRoot /www/htdocs/tweakers.www
>     ServerAlias www.tweakers.net
> </VirtualHost>
> # vhost 2
> <VirtualHost *>
>     DocumentRoot /www/htdocs/tweakers
>     ServerAlias *.tweakers.net
> </VirtualHost>
> 
> and a request for test.tweakers.net comes in, wich docroot will get used?
> three posibilities ofcourse: /www/htdocs, /www/htdocs/tweakers or
> /www/htdocs/tweakers.www. And why?

/www/htdocs/tweakers

Assuming you have "NameVirtualHost *", the /www/htdocs documentroot will 
NEVER get used.  *.tweakers.net matches test.tweakers.net, so that vhost 
will be used. The exact matching algorithm is described in 
http://httpd.apache.org/docs-2.0/vhosts/name-based.html in the paragraph 
that starts "Now when a request arrives ...".

Joshua.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org