4.3 Setting up a virtual server machine (virtual host)

Virtual host represents one server machine as multiple server machines. The two methods to set up a virtual host are as follows:

Organization of this section
(1) Virtual host based on server name
(2) Virtual host based on IP address

(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.

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 <Cosminexus-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 <Cosminexus-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).

Port 80                                                 ... 1.
NameVirtualHost 172.17.40.10                            ... 2.
<VirtualHost 172.17.40.10>                              ... 3.
DocumentRoot "<Cosminexus-installation-directory>/httpsd/htdocs1"  ... 4.
ServerName www1.xxx.soft.hitachi.co.jp                  ... 5.
</VirtualHost>
<VirtualHost 172.17.40.10>                              ... 6.
DocumentRoot "<Cosminexus-installation-directory>/httpsd/htdocs2"  ... 7.
ServerName www2.xxx.soft.hitachi.co.jp                  ... 8.
</VirtualHost>
<VirtualHost 172.17.40.10>                              ... 9.
DocumentRoot "<Cosminexus-installation-directory>/httpsd/htdocs3"  ... 10.
ServerName www3.xxx.soft.hitachi.co.jp                  ... 11.
</VirtualHost>

  1. A port number
  2. IP address of the virtual host based on server name
  3. Definition of virtual host 1
  4. Definition of root directory
  5. Definition of server name 1
  6. Definition of virtual host 2
  7. Definition of root directory
  8. Definition of server name 2
  9. Definition of virtual host 3
  10. Definition of root directory
  11. Definition of server name 3
#: 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.
[Figure]

(2) Virtual host based on IP address

The IP address-based virtual host appears as multiple hosts to clients by the following three methods:

Example 1: Open two ports on a Web server on a single server machine, and run as two hosts, one as a Web server that supports SSL and the other as a Web server that does not support SSL.

Listen 443                                                                             ...1
Listen 80                                                                              ...2
SSLDisable                                                                             ...3
<VirtualHost xxx.soft.hitachi.co.jp:443>                                               ...4
   DocumentRoot "<Cosminexus-installation-directory>/httpsd/ssldocs"
   SSLEnable                                                                          ...5
   SSLCertificateFile "<Cosminexus-installation-directory>/httpsd/conf/ssl/server/httpsd.pem"
   SSLCertificateKeyFile "<Cosminexus-installation-directory>/httpsd/conf/ssl/server/httpsdkey.pem"
</VirtualHost>
<VirtualHost xxx.soft.hitachi.co.jp:80>                                                ...6
   DocumentRoot "<Cosminexus-installation-directory>/httpsd/htdocs"
   SSLDisable                                                                         ...7
</VirtualHost>

  1. Definition of port number
  2. Definition of port number
  3. Disable SSL in the main server
  4. Definition of virtual host of port number 443
  5. Enable SSL
  6. Definition of Virtual host of port number 80
  7. Disable SSL

    [Figure]

Example 2: Provide two NIC (Network Interface Card) (IP address: 172.17.40.10 and 172.17.40.20) on a single server machine, and switch hosts according to Web browser requests, on a single Web server.
If the request from Web browser is http://172.17.40.10/, see <Cosminexus-installation-directory>/httpsd/htdocs1/index.html (when DirectoryIndex is specified as index.html).
If the request from Web browser is http://172.17.40.20/, see <Cosminexus-installation-directory>/httpsd/htdocs2/index.html (when DirectoryIndex is specified as index.html).

Port 80
<VirtualHost 172.17.40.10>
DocumentRoot "<Cosminexus-installation-directory>/httpsd/htdocs1"
ServerName www10.xxx.soft.hitachi.co.jp
</VirtualHost>
<VirtualHost 172.17.40.20>
DocumentRoot "<Cosminexus-installation-directory>/httpsd/htdocs2"
ServerName www20.xxx.soft.hitachi.co.jp
</VirtualHost>

[Figure]