Friday, June 7, 2013

Name-based vs. IP-based Virtual Hosts

Name-based vs. IP-based Virtual Hosts

IP-based virtual hosts use the IP address of the connection to determine the correct virtual host to serve. Therefore you need to have a separate IP address for each host. With name-based virtual hosting, the server relies on the client to report the hostname as part of the HTTP headers. Using this technique, many different hosts can share the same IP address.

Name-based virtual hosting is usually simpler, since you need only configure your DNS server to map each hostname to the correct IP address and then configure the Apache HTTP Server to recognize the different hostnames. Name-based virtual hosting also eases the demand for scarce IP addresses. Therefore you should use name-based virtual hosting unless you are using equipment that explicitly demands IP-based hosting. Historical reasons for IP-based virtual hosting based on client support are no longer applicable to a general-purpose web server, unless you are using a mod_ssl version without SNI support (standard in Apache releases since 2.2.12).

Using Name-based Virtual Hosts

Related Modules
core

Related Directives
DocumentRoot
NameVirtualHost
ServerAlias
ServerName
ServerPath
<VirtualHost>

For more infomation : apache.org

Apache Virtual Host documentation

The term Virtual Host refers to the practice of running more than one web site (such as company1.example.com and company2.example.com) on a single machine. Virtual hosts can be "IP-based", meaning that you have a different IP address for every web site, or "name-based", meaning that you have multiple names running on each IP address. The fact that they are running on the same physical server is not apparent to the end user.

Apache was one of the first servers to support IP-based virtual hosts right out of the box. Versions 1.1 and later of Apache support both IP-based and name-based virtual hosts (vhosts). The latter variant of virtual hosts is sometimes also called host-based or non-IP virtual hosts.

Below is a list of documentation pages which explain all details of virtual host support in Apache HTTP Server:

Virtual Host Support
- Name-based Virtual Hosts (More than one web site per IP address)
- IP-based Virtual Hosts (An IP address for each web site)
- Virtual Host examples for common setups
- File Descriptor Limits (or, Too many log files)
- Dynamically Configured Mass Virtual Hosting
- In-Depth Discussion of Virtual Host Matching

More : apache.org