VirtualHost on Apache
There are two basic kinds of virtual hosts: those that are based on having a unique IP address, and those which share IP addresses but have different names. The latter are much more common on the Web these days, but the former are still in heavy use in organisations with relatively few sites being hosted per Web server.
Vhosts which have their own IP addresses are called IP-Based virtual hosts, and those that share an address are called Name-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 separate IP address for each host. With the 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 simplier, since you only need to configure your DNS server to map each hostname to the correct IP address and then configure Apache HTTP Server to recognize the different hostnames. This may sound great, but here are 3 problems with using name-based virtual hosting:
Some clients are not compatible with name-based virtual hosting because they are ancient. For name-based virtual hosting to work, the client must send the HTTP Host header.
Name-based virtual hosting cannot be used with SSL secure servers because of the nature of the SSL protocol.
Some operating systems and network equipment implement bandwith management that cannot differentiate between hosts unless they are on separate IP addresses.
Example: You have multiple domains going to the same IP and also want to serve multiple ports. By defining the ports in the NameVirtualHost tag, you can allow this to work. You must match the to the NameVirtualHost name:port. If you do not, the configuration will not work.
NameVirtualHost 192.168.0.1:80
NameVirtualHost 192.168.0.1:8080
<VirtualHost 192.168.0.1:80>
ServerName www.domain.com
DocumentRoot /www/domain.com
</VirtualHost>
<VirtualHost 192.168.0.1:8080>
ServerName www.domain.com
DocumentRoot /www/domain.com
</VirtualHost>
Back to main page
Copyright © 2003-2016
The UnixCities.com
All rights reserved