Apache supports three flavors of virtual
hosts:
- IP-based virtual hosts
-
In this form, each virtual host uses its own IP address. Under Unix,
multiple IP addresses are assigned to the same network interface
using the ifconfig utility. These additional IP
addresses are sometimes called virtual addresses
or IP aliases. IP-based virtual hosting is the
oldest form of virtual hosting. Due to the supposed increasing
scarcity of IP addresses and ensuing difficulty in obtaining large
network blocks in some parts of the world, IP-based virtual hosting
is now less preferred than name-based virtual hosting.
- Name-based virtual hosts
-
Name-based virtual hosts share a single IP address. Apache dispatches
requests to the appropriate virtual host by examining the
Host: HTTP header field. This
field's value is the hostname extracted from the
requested URI. Although this header is mandatory for HTTP 1.1
clients, it has also been widely used by HTTP 1.0 clients for many
years.
- Port-based virtual hosts
-
In this setup, all virtual hosts share the same IP address, but each
uses its own unique port number. As we'll discuss in
the next section, port-based virtual hosts are mostly useful for
backend servers not directly accessible from Internet clients.
- Mixed flavors
-
It is perfectly possible to mix the various virtual host flavors in
one server.