4.3.1 Virtual host based on server name
Server name-based virtual host defines multiple host names for one IP address in a server such as the DNS server and when clients access this host name, it appears as multiple hosts. You need not set multiple network interfaces. In the server name-based virtual host, you cannot build hosts for a combination of SSL and non-SSL, or for various SSLs. When you build hosts for these combinations, build by IP address-based virtual hosts. For a server name-based virtual host, explicitly specify its IP address in the <VirtualHost> directive.
- Example: Open a port on one Web server machine (IP address: 172.17.40.10), and switch hosts according to Web browser requests.
-
If the request from Web browser is http://www1.xxx.soft.hitachi.co.jp/, see Application Server-installation-directory/httpsd/htdocs1/index.html (when DirectoryIndex is specified as index.html).
If the request from Web browser is http://www3.xxx.soft.hitachi.co.jp/, see Application Server-installation-directory/httpsd/htdocs3/index.html (when DirectoryIndex is specified as index.html).
However, you can use this method only when the host name (or the port number when required) is defined in the Host header during the request from the Web browser as Host: www1.xxx.soft.hitachi.co.jp. Note that this method cannot be used in old and simple Web browsers. In such cases, specifications of <VirtualHost> block coded at the topmost location are enabled (In this example www1.xxx.soft.hitachi.co.jp).
Listen 80 ... 1. <VirtualHost 172.17.40.10> ... 2. DocumentRoot "Application-Server-installation-directory/httpsd/htdocs1" ... 3. ServerName www1.xxx.soft.hitachi.co.jp ... 4. </VirtualHost> <VirtualHost 172.17.40.10> ... 5. DocumentRoot "Application-Server-installation-directory/httpsd/htdocs2" ... 6. ServerName www2.xxx.soft.hitachi.co.jp ... 7. </VirtualHost> <VirtualHost 172.17.40.10> ... 8. DocumentRoot "Application-Server-installation-directory/httpsd/htdocs3" ... 9. ServerName www3.xxx.soft.hitachi.co.jp ... 10. </VirtualHost>
-
A port number
-
Definition of virtual host 1
-
Definition of root directory
-
Definition of server name 1
-
Definition of virtual host 2
-
Definition of root directory
-
Definition of server name 2
-
Definition of virtual host 3
-
Definition of root directory
-
Definition of server name 3
Note: You must register www1.xxx.soft.hitachi.co.jp, www2.xxx.soft.hitachi.co.jp, and www3.xxx.soft.hitachi.co.jp with the DNS server as host names of the host 172.17.40.10.
-