Virtual Host Directives
|Description||Nominates an IP address as using name based virtual hosting|
The NameVirtualHost directive specifies that an IP address will be used for name based virtual hosting. Appweb provides two virtual hosting mechanisms:
IP based virtual hosting uses a dedicated IP address for each virtual host on a server. Name based hosting uses one IP address for a set of virtual hosts that are distinguished from each other by a "Host" HTTP header.
The IPAddress argument may be "*" in which case addresses on which Appweb is listening will use name based virtual hosting.
Example of Name Based Virtual Hosting
This example shows two virtual hosts with independent document webs. Both share the same IP address and use the "Host" HTTP header to select the appropriate virtual host.
NameVirtualHost 18.104.22.168 <VirtualHost 22.214.171.124> ServerName www.acme.com DocumentRoot /var/www/acme ... </VirtualHost> <VirtualHost 126.96.36.199> ServerName www.coyote.com DocumentRoot /var/www/coyote ... </VirtualHost>
Example of IP Based Virtual Hosting
This example shows two virtual hosts with independent document webs. Each has a dedicated IP address.
<VirtualHost 188.8.131.52> ServerName www.acme.com DocumentRoot /var/www/acme ... </VirtualHost> <VirtualHost 184.108.40.206> ServerName www.coyote.com DocumentRoot /var/www/coyote ... </VirtualHost>
You can use both IP based and name based hosting on one server.
You should only ever use an IP address for the argument to the directive. Using a host name will cause a DNS lookup which makes the availability of your web server dependent on the DNS server.
|Description||Create a new directive block that applies to a specific IP address. The VirtualHost block inherits the existing configuration at the point of the opening VirtualHost directive.|
|Synopsis||<VirtualHost [IPaddress][:port] [, [IPaddress][:port]]...>
<VirtualHost *:80 *:8080> ServerName www.acme.com DocumentRoot /var/www/acme .... </VirtualHost>
The VirutalHost directive defines a block of directives that will apply to the nominated IP addresses. The IP addresses specify the set of IP addresses for this VirtualHost. Note: this does not cause Appweb to listen on these addresses. You will still need an appropriate Listen directive for each IP address. The IP address is of the form IP:PORT where the IP or PORT portion may be omitted. The IP address can be set to "*" in which case the VirtualHost will listen on all interfaces.
If the IP address is also specified in a NameVirtualHost directive, the virtual host will use name based hosting. This requires the browser (as nearly all modern browsers do), to include the domain portion of the URL in the HTTP host header. Appweb examines this header and routes the request to the Virtual Host that has a corresponding ServerName
NOTE: Multiple IP addresses may be specified per VirtualHost directive.
The ServerName may begin with a "*" which means match any hosts that contains the following host name. For example "*.example.com" will then match blog.example.com and www.example.com. If the ServerName ends with "*" it will match any domain that contains the name. You can also set the ServerName to a regular expression such that it will match multiple domains. Regular expressions begin and end with a "/".