_default_
vhosts
ServerPath
directive
Server configuration:
... Port 80 DocumentRoot /www/domain ServerName www.domain.tld <VirtualHost 111.22.33.55> DocumentRoot /www/otherdomain ServerName www.otherdomain.tld ... </VirtualHost>www.otherdomain.tld can only be reached through the address 111.22.33.55, while www.domain.tld can only be reached through 111.22.33.44 (which represents our main server).
Server configuration:
... Port 80 ServerName server.domain.tld <VirtualHost 111.22.33.44> DocumentRoot /www/domain ServerName www.domain.tld ... </VirtualHost> <VirtualHost 111.22.33.55> DocumentRoot /www/otherdomain ServerName www.otherdomain.tld ... </VirtualHost>The main server can never catch a request, because all IP addresses of our machine are in use for IP-based virtual hosts (only localhost requests can hit the main server).
Server configuration:
... Port 80 Listen 111.22.33.44:80 Listen 111.22.33.55:8080 ServerName server.domain.tld <VirtualHost 111.22.33.44:80> DocumentRoot /www/domain ServerName www.domain.tld ... </VirtualHost> <VirtualHost 111.22.33.55:8080> ServerName www-cache.domain.tld ... <Directory proxy:> order deny,allow deny from all allow from 111.22.33 </Directory> </VirtualHost>The main server can never catch a request, because all IP addresses (apart from localhost) of our machine are in use for IP-based virtual hosts. The web server can only be reached on the first address through port 80 and the proxy only on the second address through port 8080.
Server configuration:
... Port 80 ServerName server.domain.tld NameVirtualHost 111.22.33.44 <VirtualHost 111.22.33.44> DocumentRoot /www/domain ServerName www.domain.tld ... </VirtualHost> <VirtualHost 111.22.33.44> DocumentRoot /www/subdomain ServerName www.sub.domain.tld ... </VirtualHost>Apart from localhost there are no unspecified addresses/ports, therefore the main server only serves localhost requests. Due to the fact that www.domain.tld has the highest priority it can be seen as the default or primary server.
Server configuration:
... Port 80 ServerName www.domain.tld DocumentRoot /www/domain NameVirtualHost 111.22.33.55 <VirtualHost 111.22.33.55> DocumentRoot /www/otherdomain ServerName www.otherdomain.tld ... </VirtualHost> <VirtualHost 111.22.33.55> DocumentRoot /www/subdomain ServerName www.sub.domain.tld ServerAlias *.sub.domain.tld ... </VirtualHost>Any request to an address other than 111.22.33.55 will be served from the main server. A request to 111.22.33.55 with an unknown or noHost:
header will be served from www.otherdomain.tld.
Server configuration:
... Port 80 ServerName server.domain.tld NameVirtualHost 111.22.33.44 <VirtualHost 111.22.33.44> DocumentRoot /www/domain ServerName www.domain.tld ... </VirtualHost> <VirtualHost 111.22.33.44> DocumentRoot /www/subdomain1 ServerName www.sub1.domain.tld ... </VirtualHost> <VirtualHost 111.22.33.44> DocumentRoot /www/subdomain2 ServerName www.sub2.domain.tld ... </VirtualHost> <VirtualHost 111.22.33.55> DocumentRoot /www/otherdomain1 ServerName www.otherdomain1.tld ... </VirtualHost> <VirtualHost 111.22.33.66> DocumentRoot /www/otherdomain2 ServerName www.otherdomain2.tld ... </VirtualHost>