details.xml revision 9967f2fc7dda1d28667d039ad2c85fe9eda080ac
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd<!-- $LastChangedRevision$ -->
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd Licensed to the Apache Software Foundation (ASF) under one or more
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd contributor license agreements. See the NOTICE file distributed with
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd this work for additional information regarding copyright ownership.
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd The ASF licenses this file to You under the Apache License, Version 2.0
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd (the "License"); you may not use this file except in compliance with
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd the License. You may obtain a copy of the License at
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd Unless required by applicable law or agreed to in writing, software
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd distributed under the License is distributed on an "AS IS" BASIS,
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4b5981e276e93df97c34e4da05ca5cf8bbd937dand See the License for the specific language governing permissions and
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd limitations under the License.
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <title>An In-Depth Discussion of Virtual Host Matching</title>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <p>This document attempts to explain
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd exactly what Apache HTTP Server does when deciding what virtual host to
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd serve a request from.</p>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <p>Most users should read about <a href="name-based.html#namevip">
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd Name-based vs. IP-based Virtual Hosts</a> to decide which type they
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd want to use, then read more about <a href="name-based.html">name-based</a>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd or <a href="ip-based.html">IP-based</a> virtualhosts, and then see
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <p>If you want to understand all the details, then you can
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd come back to this page.</p>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd<seealso><a href="ip-based.html">IP-based Virtual Host Support</a></seealso>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd<seealso><a href="name-based.html">Name-based Virtual Hosts Support</a></seealso>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd<seealso><a href="examples.html">Virtual Host examples for common setups</a></seealso>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd<seealso><a href="mass.html">Dynamically configured mass virtual hosting</a></seealso>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd<section id="configparsing"><title>Configuration File</title>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <p>There is a <em>main server</em> which consists of all the
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd definitions appearing outside of
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <p>There are virtual
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <directive type="section" module="core">VirtualHost</directive>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd sections.</p>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd or more addresses and optional ports.</p>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <p>Hostnames can be used in place of IP addresses in a virtual
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd host definition, but they are resolved at startup and if any name
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd resolutions fail, those virtual host definitions are ignored.
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd This is, therefore, not recommended.</p>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <p>The address can be specified as
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd other vhost has the explicit address on which the request was
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd received. </p>
71fccc298df6a1540d408151a26aa22beed55d0bnd directive can have an optional port. If the port is unspecified,
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd it is treated as a wildcard port, which can also be indicated
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd The wildcard port matches any port.</p>
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <p>(Port numbers specified in the <code>VirtualHost</code> directive do
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd not influence what port numbers Apache will listen on, they only control
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd which <code>VirtualHost</code> will be selected to handle a request.
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd Use the <directive module="mpm_common">Listen</directive> directive to
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd control the addresses and ports on which the server listens.)
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd <p>Collectively the
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd entire set of addresses (including multiple
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd results from DNS lookups) are called the vhost's
f3ec420152ca921e4c1ce77782f51b53f659018dnd <p>Apache automatically discriminates on the
f3ec420152ca921e4c1ce77782f51b53f659018dnd basis of the HTTP <code>Host</code> header supplied by the client
6116c12fdd3ed06d388fe6572e50a22e9320dfa5nd whenever the most specific match for an IP address and port combination
6eed902e5b4d3e016e220bfbf8769a87c4cb242enoodl is listed in multiple virtual hosts.</p>