This topic provides information about how to set up virtual hosts on your HTTP Server with the IBM® Web Administration for i5/OS™ interface.
Virtual hosts allow more than one Web site on one system or Web server. The servers are differentiated by their host name. Visitors to the Web site are routed by host name or IP address to the correct virtual host. Virtual hosting allows companies sharing one server to each have their own domain names. For example, www.company1.com and www.company2.com can both be hosted on the same server. See Virtual hosts on HTTP Server for more information.
You can configure virtual hosts by doing the following:
The name-based virtual host allows one IP address to host more than one Web site (hostname). This approach allows a single HTTP Server to service requests directed at many different hostnames. This simplifies configuration and use, and requires no additional hardware or software. The main disadvantage to this approach is that the client must support HTTP 1.1 (or HTTP 1.0 with 1.1 extensions) that include the server hostname information inside the HTTP document requests. The latest versions of most browsers support HTTP 1.1 (or HTTP 1.0 with 1.1 extensions), but there are still old browsers that only support HTTP 1.0. For more information on virtual hosts refer to the <VirtualHost> directive.
The IP-based virtual host requires one IP address per Web site (host name). This approach works very well, but requires a dedicated IP address for every virtual host. For more information on virtual hosts refer to the <VirtualHost> directive.
Use the Mass-dynamic tab to create a dynamic virtual host with a Name-based or IP-based virtual host, or work with canonical names. A canonical name is the actual name of an HTTP Server resource. For example, a canonical name of the HTTP Server powered by Apache) is its true name rather than an alias. See directive <UseCanonicalName> for more information.
The dynamic virtual host allows you to dynamically add Web sites (hostnames) by adding directories of content. This approach is based on automatically inserting the IP address and the contents of the Host: header into the pathname of the file that is used to satisfy the request.
The Mass-dynamic tab provides a subset of options that are more complex than those provided by the other tabs. The options include specifying the root directory for serving files, and selecting the root directory for CGI scripts. The availability of these settings are dependent on what server area you are working with.
At the global configuration server area, all mass-dynamic settings are available. These include:
The mass-dynamic settings use strings and substrings to create a dynamic virtual hosts. For example, to create a simple dynamic virtual host, the Root directory for serving files option is defined as /usr/local/apache/vhosts/%0 and Use server name is selected. A request for http://www.ibm.com/directory/file.html returns /usr/local/apache/vhosts/www.ibm.com/directory/file.html.
The string %0 is an interpolate (insert) string of the server name or IP address. The following defines the interpolate string:
Interpolate (insert) strings | |
---|---|
%% | inserts a % |
%p | inserts the port number of the virtual host |
%N.M | inserts (part of) the name |
N and M are used to specify substrings of the name. N selects from the period-separated components of the name, and M selects characters within whatever N has selected. M is optional and defaults to zero if it is not present; the period must be present if and only if M is present. The interpretation is as follows:
Substring interpretation | |
---|---|
0 | the whole name |
1 | the first part |
2 | the second part |
-1 | the last part |
-2 | the next to last part |
2+ | the second and all subsequent parts |
-2+ | the next to last part and all preceding parts |
1+ and -1+ | the same as 0 |
For more information on mass-dynamic virtual hosts refer to mod_vhost_alias.