details.html.en revision 378b5789dab3a2cd1b4b96ac8e6636ee61024c82
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess This file is generated from xml source: DO NOT EDIT
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5a58787efeb02a1c3f06569d019ad81fd2efa06end<title>An In-Depth Discussion of Virtual Host Matching - Apache HTTP Server</title>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
5a58787efeb02a1c3f06569d019ad81fd2efa06end<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen<link href="/images/favicon.ico" rel="shortcut icon" /></head>
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="/faq/">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p>
d229f940abfb2490dee17979e9a5ff31b7012eb5rbowen<div class="up"><a href="./"><img title="<-" alt="<-" src="/images/left.gif" /></a></div>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs-project/">Documentation</a> > <a href="../">Version 2.1</a> > <a href="./">Virtual Hosts</a></div><div id="page-content"><div id="preamble"><h1>An In-Depth Discussion of Virtual Host Matching</h1>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<p><span>Available Languages: </span><a href="/en/vhosts/details.html" title="English"> en </a> |
3f08db06526d6901aa08c110b5bc7dde6bc39905nd<a href="/ko/vhosts/details.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p>
4b3a8afbfcea8b265d179a122bf40dfedd1ce280takashi <p>The virtual host code was completely rewritten in
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung <strong>Apache 1.3</strong>. This document attempts to explain
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd exactly what Apache does when deciding what virtual host to
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd serve a hit from. With the help of the new
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <code class="directive"><a href="/mod/core.html#namevirtualhost">NameVirtualHost</a></code>
15107611640cec4e666dd7e2e1dee15c270e9e98rbowen directive virtual host configuration should be a lot easier and
15107611640cec4e666dd7e2e1dee15c270e9e98rbowen safer than with versions prior to 1.3.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>If you just want to <cite>make it work</cite> without
60a4b2c422dcbb08a554fb193105c08da592718bpoirier understanding how, here are <a href="examples.html">some
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<div id="quickview"><ul id="toc"><li><img alt="" src="/images/down.gif" /> <a href="#configparsing">Config File Parsing</a></li>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<li><img alt="" src="/images/down.gif" /> <a href="#hostmatching">Virtual Host Matching</a></li>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<li><img alt="" src="/images/down.gif" /> <a href="#tips">Tips</a></li>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<h2><a name="configparsing" id="configparsing">Config File Parsing</a></h2>
5a58787efeb02a1c3f06569d019ad81fd2efa06end <p>There is a <em>main_server</em> which consists of all the
60a4b2c422dcbb08a554fb193105c08da592718bpoirier definitions appearing outside of
5a58787efeb02a1c3f06569d019ad81fd2efa06end <code><VirtualHost></code> sections. There are virtual
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <code class="directive"><a href="/mod/core.html#virtualhost"><VirtualHost></a></code>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess sections.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>The directives
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <code class="directive"><a href="/mod/mpm_common.html#listen">Listen</a></code>,
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <code class="directive"><a href="/mod/core.html#servername">ServerName</a></code>,
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <code class="directive"><a href="/mod/core.html#serverpath">ServerPath</a></code>,
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess and <code class="directive"><a href="/mod/core.html#serveralias">ServerAlias</a></code>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess can appear anywhere within the definition of a server. However,
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess each appearance overrides the previous appearance (within that
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess server).</p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>The default value of the <code>Listen</code> field for
60a4b2c422dcbb08a554fb193105c08da592718bpoirier main_server is 80. The main_server has no default
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <code>ServerPath</code>, or <code>ServerAlias</code>. The
60a4b2c422dcbb08a554fb193105c08da592718bpoirier default <code>ServerName</code> is deduced from the server's IP
60a4b2c422dcbb08a554fb193105c08da592718bpoirier address.</p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>The main_server Listen directive has two functions. One
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf function is to determine the default network port Apache will
60a4b2c422dcbb08a554fb193105c08da592718bpoirier bind to. The second function is to specify the port number
60a4b2c422dcbb08a554fb193105c08da592718bpoirier which is used in absolute URIs during redirects.</p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>Unlike the main_server, vhost ports <em>do not</em> affect
60a4b2c422dcbb08a554fb193105c08da592718bpoirier what ports Apache listens for connections on.</p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>Each address appearing in the <code>VirtualHost</code>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier directive can have an optional port. If the port is unspecified
60a4b2c422dcbb08a554fb193105c08da592718bpoirier it defaults to the value of the main_server's most recent
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <code>Listen</code> statement. The special port <code>*</code>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier indicates a wildcard that matches any port. Collectively the
60a4b2c422dcbb08a554fb193105c08da592718bpoirier entire set of addresses (including multiple <code>A</code>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier record results from DNS lookups) are called the vhost's
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>Unless a <code class="directive"><a href="/mod/core.html#namevirtualhost">NameVirtualHost</a></code>
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf directive is used for a specific IP address the first vhost
60a4b2c422dcbb08a554fb193105c08da592718bpoirier with that address is treated as an IP-based vhost. The IP
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>If name-based vhosts should be used a
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <code>NameVirtualHost</code> directive <em>must</em> appear
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf with the IP address set to be used for the name-based vhosts.
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf In other words, you must specify the IP address that holds the
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf hostname aliases (CNAMEs) for your name-based vhosts via a
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf <code>NameVirtualHost</code> directive in your configuration
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>Multiple <code>NameVirtualHost</code> directives can be used
60a4b2c422dcbb08a554fb193105c08da592718bpoirier each with a set of <code>VirtualHost</code> directives but only
60a4b2c422dcbb08a554fb193105c08da592718bpoirier one <code>NameVirtualHost</code> directive should be used for
60a4b2c422dcbb08a554fb193105c08da592718bpoirier each specific IP:port pair.</p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <code>VirtualHost</code> directives is not important which
60a4b2c422dcbb08a554fb193105c08da592718bpoirier makes the following two examples identical (only the order of
60a4b2c422dcbb08a554fb193105c08da592718bpoirier the <code>VirtualHost</code> directives for <em>one</em>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier address set is important, see below):</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess NameVirtualHost 111.22.33.44<br />
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <VirtualHost 111.22.33.44><br />
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess # server A<br />
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess </VirtualHost><br />
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <VirtualHost 111.22.33.44><br />
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess # server B<br />
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess </VirtualHost><br />
ad79e6242f42c1915d14628f8bf44f04b129716arbowen NameVirtualHost 111.22.33.55<br />
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <VirtualHost 111.22.33.55><br />
60a4b2c422dcbb08a554fb193105c08da592718bpoirier # server C<br />
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess </VirtualHost><br />
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <VirtualHost 111.22.33.55><br />
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess # server D<br />
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess </VirtualHost>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <VirtualHost 111.22.33.44><br />
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess # server A<br />
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess </VirtualHost><br />
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <VirtualHost 111.22.33.55><br />
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess # server C<br />
60a4b2c422dcbb08a554fb193105c08da592718bpoirier </VirtualHost><br />
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <VirtualHost 111.22.33.44><br />
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess # server B<br />
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess </VirtualHost><br />
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <VirtualHost 111.22.33.55><br />
9bcfc3697a91b5215893a7d0206865b13fc72148nd # server D<br />
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess </VirtualHost><br />
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess NameVirtualHost 111.22.33.44<br />
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess NameVirtualHost 111.22.33.55<br />
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>(To aid the readability of your configuration you should
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess prefer the left variant.)</p>
5a58787efeb02a1c3f06569d019ad81fd2efa06end <p>After parsing the <code>VirtualHost</code> directive, the
5a58787efeb02a1c3f06569d019ad81fd2efa06end vhost server is given a default <code>Listen</code> equal to the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess port assigned to the first name in its <code>VirtualHost</code>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess directive.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>The complete list of names in the <code>VirtualHost</code>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier directive are treated just like a <code>ServerAlias</code> (but
60a4b2c422dcbb08a554fb193105c08da592718bpoirier are not overridden by any <code>ServerAlias</code> statement)
60a4b2c422dcbb08a554fb193105c08da592718bpoirier if all names resolve to the same address set. Note that
60a4b2c422dcbb08a554fb193105c08da592718bpoirier subsequent <code>Listen</code> statements for this vhost will not
60a4b2c422dcbb08a554fb193105c08da592718bpoirier affect the ports assigned in the address set.</p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>During initialization a list for each IP address is
60a4b2c422dcbb08a554fb193105c08da592718bpoirier generated and inserted into an hash table. If the IP address is
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess used in a <code>NameVirtualHost</code> directive the list
60a4b2c422dcbb08a554fb193105c08da592718bpoirier contains all name-based vhosts for the given IP address. If
60a4b2c422dcbb08a554fb193105c08da592718bpoirier there are no vhosts defined for that address the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <code>NameVirtualHost</code> directive is ignored and an error
60a4b2c422dcbb08a554fb193105c08da592718bpoirier is logged. For an IP-based vhost the list in the hash table is
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>Due to a fast hashing function the overhead of hashing an IP
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess address during a request is minimal and almost not existent.
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess Additionally the table is optimized for IP addresses which vary
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess in the last octet.</p>
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf <p>For every vhost various default values are set. In
4cb65c31bc681540ea623e1cb2bdd09749fb8d7esf particular:</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <li>If a vhost has no <code class="directive"><a href="/mod/core.html#serveradmin">ServerAdmin</a></code>,
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <code class="directive"><a href="/mod/core.html#resourceconfig">ResourceConfig</a></code>,
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <code class="directive"><a href="/mod/core.html#accessconfig">AccessConfig</a></code>,
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <code class="directive"><a href="/mod/core.html#timeout">Timeout</a></code>,
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <code class="directive"><a href="/mod/core.html#keepalivetimeout">KeepAliveTimeout</a></code>,
4cb65c31bc681540ea623e1cb2bdd09749fb8d7esf <code class="directive"><a href="/mod/core.html#keepalive">KeepAlive</a></code>,
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf <code class="directive"><a href="/mod/core.html#maxkeepaliverequests">MaxKeepAliveRequests</a></code>,
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf or <code class="directive"><a href="/mod/core.html#sendbuffersize">SendBufferSize</a></code>
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf directive then the respective value is inherited from the
60a4b2c422dcbb08a554fb193105c08da592718bpoirier main_server. (That is, inherited from whatever the final
60a4b2c422dcbb08a554fb193105c08da592718bpoirier setting of that value is in the main_server.)</li>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <li>The "lookup defaults" that define the default directory
60a4b2c422dcbb08a554fb193105c08da592718bpoirier permissions for a vhost are merged with those of the
60a4b2c422dcbb08a554fb193105c08da592718bpoirier main_server. This includes any per-directory configuration
60a4b2c422dcbb08a554fb193105c08da592718bpoirier information for any module.</li>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <li>The per-server configs for each module from the
60a4b2c422dcbb08a554fb193105c08da592718bpoirier main_server are merged into the vhost server.</li>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>Essentially, the main_server is treated as "defaults" or a
60a4b2c422dcbb08a554fb193105c08da592718bpoirier "base" on which to build each vhost. But the positioning of
60a4b2c422dcbb08a554fb193105c08da592718bpoirier these main_server definitions in the config file is largely
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess irrelevant -- the entire config of the main_server has been
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess parsed when this final merging occurs. So even if a main_server
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess definition appears after a vhost definition it might affect the
60a4b2c422dcbb08a554fb193105c08da592718bpoirier vhost definition.</p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>If the main_server has no <code>ServerName</code> at this
60a4b2c422dcbb08a554fb193105c08da592718bpoirier point, then the hostname of the machine that httpd is running
60a4b2c422dcbb08a554fb193105c08da592718bpoirier on is used instead. We will call the <em>main_server address
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess set</em> those IP addresses returned by a DNS lookup on the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess name-based vhost defaults to the address given first in the
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <code>VirtualHost</code> statement defining the vhost.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>Any vhost that includes the magic <code>_default_</code>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier wildcard is given the same <code>ServerName</code> as the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess main_server.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess<h2><a name="hostmatching" id="hostmatching">Virtual Host Matching</a></h2>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>The server determines which vhost to use for a request as
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess follows:</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <h3><a name="hashtable" id="hashtable">Hash table lookup</a></h3>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>When the connection is first made by a client, the IP
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess address to which the client connected is looked up in the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess internal IP hash table.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>If the lookup fails (the IP address wasn't found) the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess request is served from the <code>_default_</code> vhost if
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess there is such a vhost for the port to which the client sent the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess request. If there is no matching <code>_default_</code> vhost
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess the request is served from the main_server.</p>
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf <p>If the IP address is not found in the hash table then the
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf match against the port number may also result in an entry
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf corresponding to a <code>NameVirtualHost *</code>, which is
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf subsequently handled like other name-based vhosts.</p>
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf <p>If the lookup succeeded (a corresponding list for the IP
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf address was found) the next step is to decide if we have to
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf deal with an IP-based or a name-base vhost.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <h3><a name="ipbased" id="ipbased">IP-based vhost</a></h3>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>If the entry we found has an empty name list then we have
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess found an IP-based vhost, no further actions are performed and
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess the request is served from that vhost.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <h3><a name="namebased" id="namebased">Name-based vhost</a></h3>
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf <p>If the entry corresponds to a name-based vhost the name list
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf contains one or more vhost structures. This list contains the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess vhosts in the same order as the <code>VirtualHost</code>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier directives appear in the config file.</p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>The first vhost on this list (the first vhost in the config
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf file with the specified IP address) has the highest priority
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess and catches any request to an unknown server name or a request
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>If the client provided a <code>Host:</code> header field the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess list is searched for a matching vhost and the first hit on a
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <code>ServerName</code> or <code>ServerAlias</code> is taken
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess and the request is served from that vhost. A <code>Host:</code>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess header field can contain a port number, but Apache always
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess matches against the real port to which the client sent the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess request.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <code>Host:</code> header field we don't know to what server
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess the client tried to connect and any existing
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <code>ServerPath</code> is matched against the URI from the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess request. The first matching path on the list is used and the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess request is served from that vhost.</p>
5a58787efeb02a1c3f06569d019ad81fd2efa06end <p>If no matching vhost could be found the request is served
5a58787efeb02a1c3f06569d019ad81fd2efa06end from the first vhost with a matching port number that is on the
5a58787efeb02a1c3f06569d019ad81fd2efa06end list for the IP to which the client connected (as already
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess mentioned before).</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <h3><a name="persistent" id="persistent">Persistent connections</a></h3>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>The IP lookup described above is only done <em>once</em> for a
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess particular TCP/IP session while the name lookup is done on
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess connection. In other words a client may request pages from
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess different name-based vhosts during a single persistent
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess connection.</p>
d05d0eb4ae6d2a5e513fc3bf2555ce33da416634nd <h3><a name="absoluteURI" id="absoluteURI">Absolute URI</a></h3>
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung <p>If the URI from the request is an absolute URI, and its
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd hostname and port match the main server or one of the
5effc8b39fae5cd169d17f342bfc265705840014rbowen configured virtual hosts <em>and</em> match the address and
d229f940abfb2490dee17979e9a5ff31b7012eb5rbowen port to which the client sent the request, then the
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd scheme/hostname/port prefix is stripped off and the remaining
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd relative URI is served by the corresponding main server or
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd virtual host. If it does not match, then the URI remains
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd untouched and the request is taken to be a proxy request.</p>
<p><span>Available Languages: </span><a href="/en/vhosts/details.html" title="English"> en </a> |
<a href="/ko/vhosts/details.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p>
<p class="apache">Copyright 1999-2004 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="/faq/">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p></div>