Virtual Hosts


Apache supports virtual hosts, which means that one instance of Apache can respond to requests directed to multiple IP addresses or hostnames as though it were multiple servers. Each IP address or hostname can then provide different content and be configured differently.

There are two types of virtual hosts: host-by-name and host-by-IP. Host-by-name relies on the FQDN the client uses in its request to Apachefor example, www.example.com versus www2.example.com. Host-by-IP examines the IP address the host resolves as and responds according to that match.

Host-by-name is handy if there is only one IP address, but Apache must support multiple FQDNs. Although you can use host-by-IP if a given Web server has aliases, Apache should serve the same content regardless of which name is used.

Virtual hosts inherit their configurations from httpd.conf Section 1 (page 815) and Section 2 (page 816). In Section 3, <VirtualHost> containers create the virtual hosts and specify directives that override inherited and default values. You can specify many virtual hosts for a single instance of Apache.

The following <VirtualHost> container sets up a host-by-name for the site named intranet.example.com. This virtual host handles requests that are directed to intranet.example.com.

<VirtualHost intranet.example.com>     ServerName intranet.example.com     DocumentRoot /usr/local/www     ErrorLog /var/log/httpd/intra.error_log     CustomLog /var/log/httpd/intra.server_log     <Directory /usr/local/www>         Order deny,allow         Deny from all         Allow from 192.168.  # allow from private subnet only     </Directory> </VirtualHost>





A Practical Guide to Red Hat Linux
A Practical Guide to Red HatВ® LinuxВ®: Fedoraв„ў Core and Red Hat Enterprise Linux (3rd Edition)
ISBN: 0132280272
EAN: 2147483647
Year: 2006
Pages: 383

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net