ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzaie_5.4.0.1/rzaiemod_vhost_alias.htm

604 lines
34 KiB
HTML
Raw Permalink Normal View History

2024-04-02 14:02:31 +00:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="topic" />
<meta name="DC.Title" content="Module mod_vhost_alias" />
<meta name="copyright" content="(C) Copyright IBM Corporation 2002,2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2002,2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rzaiemod_vhost_alias" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Module mod_vhost_alias</title>
</head>
<body id="rzaiemod_vhost_alias"><a name="rzaiemod_vhost_alias"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<!--Java sync-link--><h1 class="topictitle1">Module mod_vhost_alias</h1>
<div><div class="important"><span class="importanttitle">Important:</span> Information
for this topic supports the latest PTF levels for HTTP Server for i5/OS .
It is recommended that you install the latest PTFs to upgrade to the latest
level of the HTTP Server for i5/OS. Some of the topics documented here are
not available prior to this update. See <a href="http://www-03.ibm.com/servers/eserver/iseries/software/http/services/service.html" target="_blank">http://www.ibm.com/servers/eserver/iseries/software/http/services/service.htm</a> <img src="www.gif" alt="Link outside Information Center" /> for more information. </div>
<p><strong>Summary</strong></p>
<p>The module mod_vhost_alias provides support for dynamically configured
mass virtual hosting. </p>
<p><strong>Virtual hosting</strong></p>
<p>The term Virtual Host refers to the practice of maintaining more than one
server on one machine or server instance, as differentiated by their apparent
hostname (or server instance name). For example, it is often desirable for
companies sharing a web server to have their own domains, with web servers
accessible as www.company1.com and www.company2.com, without requiring the
user to know extra path information.</p>
<p>HTTP Server (powered by Apache) supports two types of virtual hosting,
they are IP-based Virtual Host and Name-based Virtual Host. As the term IP-based
indicates, the server must have a different IP address for each IP-based virtual
host. This can be achieved by the machine having several physical network
connections, or by use of virtual interfaces that are supported by most modern
operating systems.</p>
<p>While the approach with IP-based Virtual Hosts works well, it is not the
most elegant solution, because a dedicated IP address is needed for every
virtual host and is hard to implement on some machines. The HTTP/1.1 protocol
contains a method for the server to identify what name it is being addressed
as.</p>
<p>The benefits of using the name-based virtual host support is a practically
unlimited number of servers, ease of configuration and use, and no additional
hardware or software requirements. The main disadvantage is that the client
must support this part of the protocol. The latest versions of most browsers
(e.g. HTTP 1.1) do, but there are still old browsers (e.g. HTTP 1.0) in use
that do not. This can cause problems, although a possible solution is addressed
below.</p>
<p><strong>Using non-IP virtual hosts</strong></p>
<p>The notable difference between IP-based and name-based virtual host configuration
is the NameVirtualHost directive that specifies an IP address that should
be used as a target for name-based virtual hosts. For example, suppose that
both www.domain.tld and www.otherdomain.tld point at the IP address 111.22.33.44.
Simply add to one of the configuration files (most likely httpd.conf or srm.conf)
code similar to the following: </p>
<pre class="block">NameVirtualHost 111.22.33.44
&lt;VirtualHost 111.22.33.44&gt;
ServerName www.domain.tld
DocumentRoot /www/domain
&lt;/VirtualHost&gt;
&lt;VirtualHost 111.22.33.44&gt;
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
&lt;/VirtualHost&gt; </pre>
<p>Of course, any additional directives can (and should) be placed into the &lt;VirtualHost&gt;
section. To make this work, make sure that the names www.domain.tld and www.otherdomain.tld
are pointing to the IP address 111.22.33.44 </p>
<div class="note"><span class="notetitle">Note:</span> When you specify an IP address in a NameVirtualHost directive, requests
to that IP address are only served by matching &lt;VirtualHost&gt;s. The main
server is never served from the specified IP address. If you start to use
virtual hosts you should stop using the main server as an independent server
and use it as a place for configuration directives that are common for all
your virtual hosts. In other words, you should add a &lt;VirtualHost&gt; section
for every server (hostname) you want to maintain on your server. </div>
<p>Additionally, many servers may want to be accessible by more than one name.
For example, the example server might want to be accessible as domain.tld,
or www2.domain.tld, assuming the IP addresses pointed to the same server.
In fact, one might want it so that all addresses at domain.tld were picked
up by the server. This is possible with the ServerAlias directive, placed
inside the &lt;VirtualHost&gt; section. For example: </p>
<pre class="block">ServerAlias domain.tld *.domain.tld</pre>
<div class="note"><span class="notetitle">Note:</span> You can use * and ? as wild-card characters. </div>
<p>You might also need ServerAlias if you are serving local users who do not
always include the domain name. For example, if local users are familiar with
typing "www" or "www.example" then you will need to add ServerAlias www www.example.
It isn't possible for the server to know what domain the client uses for their
name resolution because the client doesn't provide that information in the
request. The ServerAlias directive provides a means for different hostnames
to point to the same virtual host. </p>
<p><strong>Dynamic virtual hosting</strong></p>
<p>A virtual host is defined by two pieces of information: its IP address,
and the contents of the Host: header in the HTTP request. The dynamic mass
virtual hosting technique is based on automatically inserting this information
into the pathname of the file that is used to satisfy the request. This is
done most easily using mod_vhost_alias. </p>
<p>A couple of things need to be `faked', that being specific parameters with
incorrect parameter values, to make the dynamic virtual host look like a normal
one. The most important is the server name which is used by HTTP Server to
generate a self referencing URLs. It is configured with the ServerName directive,
and it is available to CGIs via the SERVER_NAME environment variable. The
actual value used at run time is controlled by the UseCanonicalName setting.
With UseCanonicalName off the server name comes from the contents of the Host:
header in the request. With UseCanonicalName DNS it comes from a reverse DNS
lookup of the virtual host's IP address. The former setting is used for name-based
dynamic virtual hosting, and the latter is used for IP-based hosting. If HTTP
Server cannot work out the server name because there is no Host: header or
the DNS lookup fails then the value configured with ServerName is used instead.
</p>
<p>The other thing to `fake' is the document root (configured with DocumentRoot
and available to CGIs via the DOCUMENT_ROOT environment variable). This setting
is used by the core module when mapping URIs to filenames, but when the server
is configured to do dynamic virtual hosting that job is taken over by the
mod_vhost_alias module. If any CGIs or SSI documents make use of the DOCUMENT_ROOT
environment variable they will therefore get a misleading value; there is
not any way to change DOCUMENT_ROOT dynamically. </p>
<p><strong>Motivation for dynamic virtual hosting</strong> </p>
<p>The techniques described here are of interest if your httpd.conf contains
many &lt;VirtualHost&gt; sections that are substantially the same. For example:
</p>
<pre class="block">NameVirtualHost 10.22.33.44
&lt;VirtualHost 10.22.33.44&gt;
ServerName www.customer-1.com
DocumentRoot /www/hosts/www.customer-1.com/docs
ScriptAlias /cgi-bin/ /www/hosts/www.customer-1.com/cgi-bin
&lt;/VirtualHost&gt;
&lt;VirtualHost 10.22.33.44&gt;
ServerName www.customer-2.com
DocumentRoot /www/hosts/www.customer-2.com/docs
ScriptAlias /cgi-bin/ /www/hosts/www.customer-2.com/cgi-bin
&lt;/VirtualHost&gt;
# comment line
&lt;VirtualHost 10.22.33.44&gt;
ServerName www.customer-N.com
DocumentRoot /www/hosts/www.customer-N.com/docs
ScriptAlias /cgi-bin/ /www/hosts/www.customer-N.com/cgi-bin
&lt;/VirtualHost&gt; </pre>
<p>The basic idea is to replace all of the static &lt;VirtualHost&gt; configuration
with a mechanism that works it out dynamically. This has a number of advantages: </p>
<ol><li>Your configuration file is smaller so HTTP Server starts faster and uses
less memory. </li>
<li>Adding virtual hosts is simply a matter of creating the appropriate directories
in the filesystem and entries in the DNS - you do not need to configure or
restart HTTP Server (powered by Apache).</li>
</ol>
<p>The main disadvantage is that you cannot have a different log file for
each virtual host; however if you have very many virtual hosts then doing
this is dubious anyway because it eats file descriptors. It is better to log
to a pipe or a fifo and arrange for the process at the other end to distribute
the logs to the customers (it can also accumulate statistics).</p>
<p>A request for http://www.example.isp.com/directory/file.html will be satisfied
by the file: </p>
<pre class="block">/usr/local/apache/vhosts/isp.com/e/x/a/example/directory/file.html. </pre>
<p>A more even spread of files can be achieved by hashing from the end of
the name, for example: </p>
<pre class="block">VirtualDocumentRoot /usr/local/apache/vhosts/%3+/%2.-1/%2.-2/%2.-3/%2</pre>
<p>The example request would come from /usr/local/apache/vhosts/isp.com/e/l/p/example/directory/file.html.
Alternatively you might use: </p>
<pre class="block">VirtualDocumentRoot /usr/local/apache/vhosts/%3+/%2.1/%2.2/%2.3/%2.4+</pre>
<p>The example request would come from /usr/local/apache/vhosts/isp.com/e/x/a/mple/directory/file.html.
</p>
<p><strong>Simple dynamic virtual hosts</strong></p>
<p>This extract from httpd.conf implements the virtual host arrangement outlined
in the Motivation section above, but in a generic fashion using mod_vhost_alias.
</p>
<pre class="block"># get the server name from the Host: header
UseCanonicalName off
# this log format can be split per-virtual-host based on the first field
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
CustomLog logs/access_log vcommon
# include the server name in the filenames used to satisfy requests
VirtualDocumentRoot /www/hosts/%0/docs
VirtualScriptAlias /www/hosts/%0/cgi-bin </pre>
<p>This configuration can be changed into an IP-based virtual hosting solution
by just turning UseCanonicalName off into UseCanonicalName DNS. The server
name that is inserted into the filename is then derived from the IP address
of the virtual host. </p>
<p><strong>A virtually hosted homepages system </strong></p>
<p>This is an adjustment of the above system tailored for an ISP's homepages
server. Using a slightly more complicated configuration we can select substrings
of the server name to use in the filename so that e.g. the documents for www.user.isp.com
are found in /home/user/. It uses a single cgi-bin directory instead of one
per virtual host. </p>
<pre class="block"># all the preliminary stuff is the same as above, then
# include part of the server name in the filenames
VirtualDocumentRoot /www/hosts/%2/docs
# single cgi-bin directory
ScriptAlias /cgi-bin/ /www/std-cgi/</pre>
<p><strong>Use more than one virtual hosting system on the same server </strong></p>
<p>With more complicated setups you can use HTTP Server's normal &lt;VirtualHost&gt;
directives to control the scope of the various virtual hosting configurations.
For example, you could have one IP address for homepages customers and another
for commercial customers with the following setup. This can of course be combined
with conventional &lt;VirtualHost&gt; configuration sections. </p>
<pre class="block">UseCanonicalName off
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
&lt;Directory /www/commercial&gt;
Options FollowSymLinks
AllowOverride All
&lt;/Directory&gt;
&lt;Directory /www/homepages&gt;
Options FollowSymLinks
AllowOverride None
&lt;/Directory&gt;
&lt;VirtualHost 10.22.33.44&gt;
ServerName www.commercial.isp.com
CustomLog logs/access_log.commercial vcommon
VirtualDocumentRoot /www/commercial/%0/docs
VirtualScriptAlias /www/commercial/%0/cgi-bin
&lt;/VirtualHost&gt;
&lt;VirtualHost 10.22.33.45&gt;
ServerName www.homepages.isp.com
CustomLog logs/access_log.homepages vcommon
VirtualDocumentRoot /www/homepages/%0/docs
ScriptAlias /cgi-bin/ /www/std-cgi/
&lt;/VirtualHost&gt;</pre>
<p><strong>Directory name interpolation</strong> </p>
<p>All the directives in this module interpolate (insert) a string into a
pathname. The interpolated string may either be the server name (see <a href="rzaiemod_core.htm#usecanonicalname">UseCanonicalName</a> for more information)
or the IP address of the virtual host on the server in dotted-quad format.
The interpolation is controlled by specifiers inspired by UNIX<sup>®</sup> printf which
have a number of formats: </p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" frame="border" border="1" rules="all"><thead align="left"><tr><th valign="top" id="d0e137">Specifier</th>
<th valign="top" id="d0e139">Description</th>
</tr>
</thead>
<tbody><tr><td valign="top" headers="d0e137 ">%%</td>
<td valign="top" headers="d0e139 ">Insert a % sign</td>
</tr>
<tr><td valign="top" headers="d0e137 ">%p</td>
<td valign="top" headers="d0e139 ">Insert the port number of the virtual host</td>
</tr>
<tr><td valign="top" headers="d0e137 ">%N.M</td>
<td valign="top" headers="d0e139 ">Insert (part of) the interpolated string</td>
</tr>
</tbody>
</table>
</div>
<p><strong>N</strong> and <strong>M</strong> are used to specify substrings of the interpolated
string. <strong>N</strong> selects from the period separated components of the interpolated
string, and <strong>M</strong> selects characters within whatever <strong>N</strong> has selected. <strong>M</strong> is
optional and defaults to zero if it is not present. The period (.) must be
present if and only if <strong>M</strong> is present. The interpretation is as follows:
</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" frame="border" border="1" rules="all"><thead align="left"><tr><th valign="top" id="d0e185">N.M interpretation</th>
<th valign="top" id="d0e187">Description</th>
</tr>
</thead>
<tbody><tr><td valign="top" headers="d0e185 ">0</td>
<td valign="top" headers="d0e187 ">The whole name.</td>
</tr>
<tr><td valign="top" headers="d0e185 ">1</td>
<td valign="top" headers="d0e187 ">The first part.</td>
</tr>
<tr><td valign="top" headers="d0e185 ">2</td>
<td valign="top" headers="d0e187 ">The second part.</td>
</tr>
<tr><td valign="top" headers="d0e185 ">-1</td>
<td valign="top" headers="d0e187 ">The last part.</td>
</tr>
<tr><td valign="top" headers="d0e185 ">-2</td>
<td valign="top" headers="d0e187 ">The next to last part.</td>
</tr>
<tr><td valign="top" headers="d0e185 ">2+</td>
<td valign="top" headers="d0e187 ">The second and all subsequent parts.</td>
</tr>
<tr><td valign="top" headers="d0e185 ">-2+</td>
<td valign="top" headers="d0e187 ">The next to last part and all preceding parts.</td>
</tr>
<tr><td valign="top" headers="d0e185 ">1+ and -1+</td>
<td valign="top" headers="d0e187 ">The same as 0 (zero).</td>
</tr>
</tbody>
</table>
</div>
<p>If <strong>N</strong> or <strong>M</strong> is greater than the number of parts available a
single underscore is interpolated.</p>
<p>For a simple name-based virtual hosts you might use the following directives
in your server configuration file: </p>
<pre class="block">UseCanonicalName off
VirtualDocumentRoot
/usr/local/www.example.isp.com/vhosts/%0
A request for http://www.example.com/directory/file.html will be satisfied by the
file /usr/local/www.example.isp.com/vhosts/www.example.com/directory/file.html.</pre>
<p>For a very large number of virtual hosts it is a good idea to arrange the
files to reduce the size of the vhosts directory. To do this you might use
the following in your configuration file:</p>
<pre class="block">UseCanonicalName off
VirtualDocumentRoot
/usr/local/www.example.isp.com/vhosts/%3+/%2.1/%2.2/%2.3/%2
A request for http://www.example.isp.com/directory/file.html will be satisfied by
the file /usr/local/www.example.isp.com/isp.com/e/x/a/example/directory/file.html.</pre>
<p>A more even spread of files can be achieved by hashing from the end of
the name, for example:</p>
<pre class="block">VirtualDocumentRoot
/usr/web/www.example.isp.com/vhosts/%3+/%2.-1/%2.-2/%2.-3/%2</pre>
<p>The example request would come from /usr/web/www.example.isp.com/vhosts/isp.com/e/l/p/example/directory/file.html.
Alternatively you might use:</p>
<pre class="block">VirtualDocumentRoot
/usr/local/www.example.isp.com/vhosts/%3+/%2.1/%2.2/%2.3/%2.4+</pre>
<p>The example request would come from /usr/web/www.example.isp.com/vhosts/isp.com/e/x/a/mple/directory/file.html.
For IP-based virtual hosting you might use the following in your configuration
file:</p>
<pre class="block">UseCanonicalName DNS
VirtualDocumentRootIP /usr/local/www.example.isp.com/vhost/%1/%2/%3/%4/docs
VirtualScriptAliasIP
/usr/local/www.example.isp.com/vhost/%1/%2/%3/%4/cgi-bin</pre>
<p>A request for http://www.example.isp.com/directory/file.html would be satisfied
by the file /usr/local/www.example.isp.com/10/20/30/40/docs/directory/file.html
if the IP address of www.example.com were 10.20.30.40. A request for http://www.example.isp.com/cgi-bin/script.pl
would be satisfied by executing the program /usr/local/www.example.isp.com/10/20/30/40/cgi-bin/script.pl. </p>
<p>The LogFormat directives %V and %A are useful in conjunction with this
module. See <a href="rzaiemod_log_config.htm#logformat">LogFormat</a> for
more information.</p>
<p><strong>Directives</strong></p>
<ul><li><a href="#virtualdocumentroot">VirtualDocumentRoot</a></li>
<li><a href="#virtualdocumentrootip">VirtualDocumentRootIP</a></li>
<li><a href="#virtualscriptalias">VirtualScriptAlias</a></li>
<li><a href="#virtualscriptaliasip">VirtualScriptAliasIP</a></li>
</ul>
</div>
<div class="hr" id="virtualdocumentroot"><a name="virtualdocumentroot"><!-- --></a><h2 class="topictitle2">VirtualDocumentRoot</h2>
<div>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" frame="void" border="0" rules="none"><tbody><tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Module">Module</a></strong>: mod_vhost_alias </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Syntax">Syntax</a></strong>: VirtualDocumentRoot <em>interpolated-directory</em> </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Default">Default</a></strong>: none </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Context">Context</a></strong>: <span id="virtualdocumentroot__virtualdocumentroot_context"><a name="virtualdocumentroot__virtualdocumentroot_context"><!-- --></a>server
config, virtual host </span></td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Override">Override</a></strong>: none </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Origin">Origin</a></strong>: <span id="virtualdocumentroot__virtualdocumentroot_origin"><a name="virtualdocumentroot__virtualdocumentroot_origin"><!-- --></a>Apache </span></td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__UsageConsiderations">Usage Considerations</a></strong>: A LoadModule is required in
the config file prior to using the directive. The statement should be as follows:
LoadModule vhost_alias_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Example">Example</a></strong>: See below.</td>
</tr>
</tbody>
</table>
</div>
<p>The VirtualDocumentRoot directive allows you to determine where the server
will finds your documents based on the value of the server name. The result
of expanding interpolated-directory is used as the root of the document tree
in a similar manner to the DocumentRoot disabled. See <a href="rzaiemod_core.htm#documentroot">DocumentRoot</a> for more information. </p>
<p>If interpolated-directory is <em>none</em> then VirtualDocumentRoot is disabled.
This directive cannot be used in the same context as VirtualDocumentRootIP.
See <a href="#virtualdocumentrootip">VirtualDocumentRootIP</a> for more information.</p>
<dl class="block"><dt class="dlterm"><strong>Parameter</strong>: <em>interpolated-directory </em></dt>
<dd><ul><li>The <em>interpolated-directory</em> parameter the full path to a directory. </li>
</ul>
</dd>
</dl>
<p>For example, a simple dynamic virtual host:</p>
<pre class="block"># LocalModule directive required
LoadModule vhost_alias_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM
# get the server name from the Host: header
UseCanonicalName off
# this log format can be split per-virtual-host based on the first field
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
CustomLog logs/access_log vcommon
# include the server name in the filenames used to satisfy requests
VirtualDocumentRoot /www/web/%0/docs</pre>
<p>The next example is an adjustment of the above, system tailored for an
ISP's homepage server. Using a slightly more complicated configuration we
can select substrings of the server name to use in the filename so that e.g.
the documents for www.user.isp.com are found in /home/user/. It uses a single
cgi-bin directory instead of one per virtual host: </p>
<pre class="block"># LocalModule directive required
LoadModule vhost_alias_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM
# get the server name from the Host: header
UseCanonicalName off
# include part of the server name in the filenames
VirtualDocumentRoot /usr/web/hosts/%2/docs
# single cgi-bin directory
ScriptAlias /cgi-bin/ /usr/web/std-cgi/ </pre>
<div class="note"><span class="notetitle">Note:</span> This configuration can be changed into an IP-based virtual hosting solution
by just turning UseCanonicalName off into UseCanonicalName DNS. The server
name that is inserted into the filename is then derived from the IP address
of the virtual host. See <a href="rzaiemod_core.htm#usecanonicalname">UseCanonicalName</a> for more information.</div>
</div>
</div>
<div class="hr" id="virtualdocumentrootip"><a name="virtualdocumentrootip"><!-- --></a><h2 class="topictitle2">VirtualDocumentRootIP</h2>
<div>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" frame="void" border="0" rules="none"><tbody><tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Module">Module</a></strong>: mod_vhost_alias </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Syntax">Syntax</a></strong>: VirtualDocumentRootIP <em>interpolated-directory</em> </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Default">Default</a></strong>: none </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Context">Context</a></strong>: <span id="virtualdocumentrootip__virtualdocumentrootip_context"><a name="virtualdocumentrootip__virtualdocumentrootip_context"><!-- --></a>server
config, virtual host </span></td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Override">Override</a></strong>: none </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Origin">Origin</a></strong>: <span id="virtualdocumentrootip__virtualdocumentrootip_origin"><a name="virtualdocumentrootip__virtualdocumentrootip_origin"><!-- --></a>Apache </span></td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__UsageConsiderations">Usage Considerations</a></strong>: A LoadModule is required in
the config file prior to using the directive. The statement should be as follows:
LoadModule vhost_alias_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Example">Example</a></strong>: See <a href="#virtualdocumentroot">VirtualDocumentRoot</a>.</td>
</tr>
</tbody>
</table>
</div>
<dl class="block"><dt class="dlterm"><strong>Parameter</strong>: <em>interpolated-directory </em></dt>
<dd><ul><li>The <em>interpolated-directory</em> parameter the full path to a directory. </li>
</ul>
</dd>
</dl>
<p>More complicated setups can use the server's normal &lt;VirtualHost&gt; directives
to control the scope of the various virtual hosting configurations. For example,
you could have one IP address for home page customers and another for commercial
customers with the following directives. This can of course be combined with
conventional &lt;VirtualHost&gt; configuration sections. </p>
<pre class="block">UseCanonicalName off
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
&lt;Directory /usr/web/commercial&gt;
Options FollowSymLinks
AllowOverride All
&lt;/Directory&gt;
&lt;Directory /usr/web/homepages&gt;
Options FollowSymLinks
AllowOverride None
&lt;/Directory&gt;
# LocalModule directive required
LoadModule vhost_alias_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM
&lt;VirtualHost 10.22.33.44&gt;
ServerName www.commercial.isp.com
CustomLog logs/access_log.commercial vcommon
VirtualDocumentRoot /usr/web/commercial/%0/docs
VirtualScriptAlias /usr/web/commercial/%0/cgi-bin
&lt;/VirtualHost&gt;
&lt;VirtualHost 10.22.33.45&gt;
ServerName www.homepages.isp.com
CustomLog logs/access_log.homepages vcommon
VirtualDocumentRoot /usr/web/homepages/%0/docs
ScriptAlias /cgi-bin/ /usr/web/std-cgi/
&lt;/VirtualHost&gt;</pre>
<p><strong>More efficient IP-based virtual hosting: </strong></p>
<p>In the first example note that it is easy to turn it into an IP-based virtual
hosting setup. Unfortunately that configuration is not very efficient because
it requires a DNS lookup for every request. This can be avoided by laying
out the filesystem according to the IP addresses themselves rather than the
corresponding names and changing the logging similarly. HTTP Server will not
usually need to work out the server name and a DNS lookup. For example:</p>
<pre class="block"># Get the server name from the reverse DNS of the IP address
UseCanonicalName DNS
# LocalModule directive required
LoadModule vhost_alias_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM
# include the IP address in the logs so they may be split
LogFormat "%A %h %l %u %t \"%r\" %s %b" vcommon
CustomLog logs/access_log vcommon
# include the IP address in the filenames
VirtualDocumentRootIP /usr/web/hosts/%0/docs
VirtualScriptAliasIP /usr/web/hosts/%0/cgi-bin</pre>
<p>The VirtualDocumentRootIP directive is like the VirtualDocumentRoot directive,
except that it uses the IP address of the server end of the connection instead
of the server name. See <a href="#virtualdocumentroot">VirtualDocumentRoot</a> for more
information.</p>
</div>
</div>
<div class="hr" id="virtualscriptalias"><a name="virtualscriptalias"><!-- --></a><h2 class="topictitle2">VirtualScriptAlias</h2>
<div>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" frame="void" border="0" rules="none"><tbody><tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Module">Module</a></strong>: mod_vhost_alias </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Syntax">Syntax</a></strong>: VirtualScriptAlias<em> interpolated-directory </em></td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Default">Default</a></strong>: none </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Context">Context</a></strong>: <span id="virtualscriptalias__virtualscriptalias_context"><a name="virtualscriptalias__virtualscriptalias_context"><!-- --></a>server
config, virtual host </span></td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Override">Override</a></strong>: none </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Origin">Origin</a></strong>: <span id="virtualscriptalias__virtualscriptalias_origin"><a name="virtualscriptalias__virtualscriptalias_origin"><!-- --></a>Apache </span></td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__UsageConsiderations">Usage Considerations</a></strong>: A LoadModule is required in
the config file prior to using the directive. The statement should be as follows:
LoadModule vhost_alias_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Example">Example</a></strong>: See below.</td>
</tr>
</tbody>
</table>
</div>
<dl class="block"><dt class="dlterm"><strong>Parameter</strong>: <em>interpolated-directory </em></dt>
<dd><ul><li>The <em>interpolated-directory</em> parameter the full path to a directory. </li>
</ul>
</dd>
</dl>
<p><strong>Using more than one virtual hosting system on the same server instance</strong>: </p>
<p>More complicated setups use the server's normal &lt;VirtualHost&gt; directives
to control the scope of the various virtual hosting configurations. For example,
you could have one IP address for homepages customers and another for commercial
customers with the following directives. This can of course be combined with
conventional &lt;VirtualHost&gt; configuration sections.</p>
<pre class="block">UseCanonicalName off
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
&lt;Directory/usr/web/commercial&gt;
Options FollowSymLinks
AllowOverride All
&lt;/Directory&gt;
&lt;Directory /usr/web/homepages&gt;
Options FollowSymLinks
AllowOverride None
&lt;/Directory&gt;
# LocalModule directive required
LoadModule vhost_alias_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM
&lt;VirtualHost 10.22.33.44&gt;
ServerName www.commercial.isp.com
CustomLog logs/access_log.commercial vcommon
VirtualDocumentRoot /usr/web/commercial/%0/docs
VirtualScriptAlias /usr/web/commercial/%0/cgi-bin
&lt;/VirtualHost&gt;
&lt;VirtualHost 10.22.33.45&gt;
ServerName www.homepages.isp.com
CustomLog logs/access_log.homepages vcommon
VirtualDocumentRoot /usr/web/homepages/%0/docs
ScriptAlias /cgi-bin/ /usr/web/std-cgi/
&lt;/VirtualHost&gt;</pre>
<div class="note"><span class="notetitle">Note:</span> The VirtualScriptAlias directive allows you to specify the directory
path where the server will find CGI scripts in a similar manner to <a href="#virtualdocumentroot">VirtualDocumentRoot</a> does
for other documents. In this case the target directory of the CGI scripts
must be named "cgi-bin". For example: </div>
<pre class="block">VirtualScriptAlias /user/web/commercial/%0/cgi-bin</pre>
</div>
</div>
<div class="hr" id="virtualscriptaliasip"><a name="virtualscriptaliasip"><!-- --></a><h2 class="topictitle2">VirtualScriptAliasIP</h2>
<div>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" frame="void" border="0" rules="none"><tbody><tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Module">Module</a></strong>: mod_vhost_alias </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Syntax">Syntax</a></strong>: VirtualScriptAliasIP<em> interpolated-directory</em> </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Default">Default</a></strong>: none </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Context">Context</a></strong>: <span id="virtualscriptaliasip__virtualscriptaliasip_context"><a name="virtualscriptaliasip__virtualscriptaliasip_context"><!-- --></a>server
config, virtual host </span></td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Override">Override</a></strong>: none </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Origin">Origin</a></strong>: <span id="virtualscriptaliasip__virtualscriptaliasip_origin"><a name="virtualscriptaliasip__virtualscriptaliasip_origin"><!-- --></a>Apache </span></td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__UsageConsiderations">Usage Considerations</a></strong>: A LoadModule is required in
the config file prior to using the directive. The statement should be as follows:
LoadModule vhost_alias_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Example">Example</a></strong>: See <a href="#virtualscriptalias">VirtualScriptAlias</a>.</td>
</tr>
</tbody>
</table>
</div>
<p>The VirtualScriptAliasIP directive is like the <a href="#virtualscriptalias">VirtualScriptAlias</a> directive,
except that it uses the IP address of the server end of the connection instead
of the server name. </p>
<dl class="block"><dt class="dlterm"><strong>Parameter</strong>: <em>interpolated-directory </em></dt>
<dd><ul><li>The <em>interpolated-directory</em> parameter the full path to a directory. </li>
</ul>
</dd>
</dl>
</div>
</div>
</body>
</html>