bind.xml revision 3d81f57512275ca06a60a9bcbd23c1f8b429fdf2
0d03aadb6c364ae976af4c904aa3625d2512d101sf<?xml version="1.0" encoding="UTF-8" ?>
0d03aadb6c364ae976af4c904aa3625d2512d101sf<!DOCTYPE manualpage SYSTEM "/style/manualpage.dtd">
0d03aadb6c364ae976af4c904aa3625d2512d101sf<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
0d03aadb6c364ae976af4c904aa3625d2512d101sf<!-- $LastChangedRevision$ -->
0d03aadb6c364ae976af4c904aa3625d2512d101sf
0d03aadb6c364ae976af4c904aa3625d2512d101sf<!--
0d03aadb6c364ae976af4c904aa3625d2512d101sf Copyright 2002-2006 The Apache Software Foundation or its licensors, as
0d03aadb6c364ae976af4c904aa3625d2512d101sf applicable.
0d03aadb6c364ae976af4c904aa3625d2512d101sf
0d03aadb6c364ae976af4c904aa3625d2512d101sf Licensed under the Apache License, Version 2.0 (the "License");
0d03aadb6c364ae976af4c904aa3625d2512d101sf you may not use this file except in compliance with the License.
0d03aadb6c364ae976af4c904aa3625d2512d101sf You may obtain a copy of the License at
0d03aadb6c364ae976af4c904aa3625d2512d101sf
0d03aadb6c364ae976af4c904aa3625d2512d101sf http://www.apache.org/licenses/LICENSE-2.0
0d03aadb6c364ae976af4c904aa3625d2512d101sf
0d03aadb6c364ae976af4c904aa3625d2512d101sf Unless required by applicable law or agreed to in writing, software
0d03aadb6c364ae976af4c904aa3625d2512d101sf distributed under the License is distributed on an "AS IS" BASIS,
0d03aadb6c364ae976af4c904aa3625d2512d101sf WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0d03aadb6c364ae976af4c904aa3625d2512d101sf See the License for the specific language governing permissions and
0d03aadb6c364ae976af4c904aa3625d2512d101sf limitations under the License.
0d03aadb6c364ae976af4c904aa3625d2512d101sf-->
0d03aadb6c364ae976af4c904aa3625d2512d101sf
0d03aadb6c364ae976af4c904aa3625d2512d101sf<manualpage metafile="bind.xml.meta">
0d03aadb6c364ae976af4c904aa3625d2512d101sf
0d03aadb6c364ae976af4c904aa3625d2512d101sf <title>Binding</title>
0d03aadb6c364ae976af4c904aa3625d2512d101sf
0d03aadb6c364ae976af4c904aa3625d2512d101sf <summary>
0d03aadb6c364ae976af4c904aa3625d2512d101sf <p>Configuring Apache to listen on specific addresses and ports.</p>
0d03aadb6c364ae976af4c904aa3625d2512d101sf </summary>
0d03aadb6c364ae976af4c904aa3625d2512d101sf
0d03aadb6c364ae976af4c904aa3625d2512d101sf <seealso><a href="vhosts/">Virtual Hosts</a></seealso>
0d03aadb6c364ae976af4c904aa3625d2512d101sf <seealso><a href="dns-caveats.html">DNS Issues</a></seealso>
0d03aadb6c364ae976af4c904aa3625d2512d101sf
0d03aadb6c364ae976af4c904aa3625d2512d101sf <section id="overview">
0d03aadb6c364ae976af4c904aa3625d2512d101sf <title>Overview</title>
0d03aadb6c364ae976af4c904aa3625d2512d101sf
0d03aadb6c364ae976af4c904aa3625d2512d101sf <related>
0d03aadb6c364ae976af4c904aa3625d2512d101sf <modulelist>
0d03aadb6c364ae976af4c904aa3625d2512d101sf <module>core</module>
0d03aadb6c364ae976af4c904aa3625d2512d101sf <module>mpm_common</module>
0d03aadb6c364ae976af4c904aa3625d2512d101sf </modulelist>
0d03aadb6c364ae976af4c904aa3625d2512d101sf <directivelist>
0d03aadb6c364ae976af4c904aa3625d2512d101sf <directive module="core" type="section">VirtualHost</directive>
0d03aadb6c364ae976af4c904aa3625d2512d101sf <directive module="mpm_common">Listen</directive>
0d03aadb6c364ae976af4c904aa3625d2512d101sf </directivelist>
0d03aadb6c364ae976af4c904aa3625d2512d101sf </related>
0d03aadb6c364ae976af4c904aa3625d2512d101sf
0d03aadb6c364ae976af4c904aa3625d2512d101sf
0d03aadb6c364ae976af4c904aa3625d2512d101sf <p>When Apache starts, it binds to some port and address on
0d03aadb6c364ae976af4c904aa3625d2512d101sf the local machine and waits for incoming requests. By default,
0d03aadb6c364ae976af4c904aa3625d2512d101sf it listens to all addresses on the machine. However, it may need to
0d03aadb6c364ae976af4c904aa3625d2512d101sf be told to listen on specific ports, or only on selected
0d03aadb6c364ae976af4c904aa3625d2512d101sf addresses, or a combination of both. This is often combined with the
0d03aadb6c364ae976af4c904aa3625d2512d101sf Virtual Host feature, which determines how Apache responds to
0d03aadb6c364ae976af4c904aa3625d2512d101sf different IP addresses, hostnames and ports.</p>
0d03aadb6c364ae976af4c904aa3625d2512d101sf
0d03aadb6c364ae976af4c904aa3625d2512d101sf <p>The <directive module="mpm_common">Listen</directive>
0d03aadb6c364ae976af4c904aa3625d2512d101sf directive tells the server to accept
0d03aadb6c364ae976af4c904aa3625d2512d101sf incoming requests only on the specified ports or
0d03aadb6c364ae976af4c904aa3625d2512d101sf address-and-port combinations. If only a port number is
0d03aadb6c364ae976af4c904aa3625d2512d101sf specified in the <directive module="mpm_common">Listen</directive>
0d03aadb6c364ae976af4c904aa3625d2512d101sf directive, the server
0d03aadb6c364ae976af4c904aa3625d2512d101sf listens to the given port on all interfaces. If an IP address
0d03aadb6c364ae976af4c904aa3625d2512d101sf is given as well as a port, the server will listen on the given
0d03aadb6c364ae976af4c904aa3625d2512d101sf port and interface. Multiple <directive
0d03aadb6c364ae976af4c904aa3625d2512d101sf module="mpm_common">Listen</directive> directives may be used to
0d03aadb6c364ae976af4c904aa3625d2512d101sf specify a number of addresses and ports to listen on. The
0d03aadb6c364ae976af4c904aa3625d2512d101sf server will respond to requests from any of the listed
0d03aadb6c364ae976af4c904aa3625d2512d101sf addresses and ports.</p>
0d03aadb6c364ae976af4c904aa3625d2512d101sf
0d03aadb6c364ae976af4c904aa3625d2512d101sf <p>For example, to make the server accept connections on both
0d03aadb6c364ae976af4c904aa3625d2512d101sf port 80 and port 8000, on all interfaces, use:</p>
0d03aadb6c364ae976af4c904aa3625d2512d101sf
0d03aadb6c364ae976af4c904aa3625d2512d101sf <example>
0d03aadb6c364ae976af4c904aa3625d2512d101sf Listen 80<br />
0d03aadb6c364ae976af4c904aa3625d2512d101sf Listen 8000
0d03aadb6c364ae976af4c904aa3625d2512d101sf </example>
0d03aadb6c364ae976af4c904aa3625d2512d101sf
0d03aadb6c364ae976af4c904aa3625d2512d101sf <p>To make the server accept connections on port 80 for one interface,
0d03aadb6c364ae976af4c904aa3625d2512d101sf and port 8080 on another, use</p>
0d03aadb6c364ae976af4c904aa3625d2512d101sf
0d03aadb6c364ae976af4c904aa3625d2512d101sf <example>
0d03aadb6c364ae976af4c904aa3625d2512d101sf Listen 192.170.2.1:80<br />
0d03aadb6c364ae976af4c904aa3625d2512d101sf Listen 192.170.2.5:8000
0d03aadb6c364ae976af4c904aa3625d2512d101sf </example>
0d03aadb6c364ae976af4c904aa3625d2512d101sf
0d03aadb6c364ae976af4c904aa3625d2512d101sf <p>IPv6 addresses must be enclosed in square brackets, as in the
0d03aadb6c364ae976af4c904aa3625d2512d101sf following example:</p>
0d03aadb6c364ae976af4c904aa3625d2512d101sf
0d03aadb6c364ae976af4c904aa3625d2512d101sf <example>
0d03aadb6c364ae976af4c904aa3625d2512d101sf Listen [2001:db8::a00:20ff:fea7:ccea]:80
0d03aadb6c364ae976af4c904aa3625d2512d101sf </example>
0d03aadb6c364ae976af4c904aa3625d2512d101sf </section>
0d03aadb6c364ae976af4c904aa3625d2512d101sf
0d03aadb6c364ae976af4c904aa3625d2512d101sf <section id="ipv6">
0d03aadb6c364ae976af4c904aa3625d2512d101sf <title>Special IPv6 Considerations</title>
0d03aadb6c364ae976af4c904aa3625d2512d101sf
0d03aadb6c364ae976af4c904aa3625d2512d101sf <p>A growing number of platforms implement IPv6, and
0d03aadb6c364ae976af4c904aa3625d2512d101sf <glossary>APR</glossary> supports IPv6 on most of these platforms,
0d03aadb6c364ae976af4c904aa3625d2512d101sf allowing Apache to allocate IPv6 sockets, and to handle requests sent
0d03aadb6c364ae976af4c904aa3625d2512d101sf over IPv6.</p>
0d03aadb6c364ae976af4c904aa3625d2512d101sf
0d03aadb6c364ae976af4c904aa3625d2512d101sf <p>One complicating factor for Apache administrators is whether or
0d03aadb6c364ae976af4c904aa3625d2512d101sf not an IPv6 socket can handle both IPv4 connections and IPv6
0d03aadb6c364ae976af4c904aa3625d2512d101sf connections. Handling IPv4 connections with an IPv6 socket uses
0d03aadb6c364ae976af4c904aa3625d2512d101sf IPv4-mapped IPv6 addresses, which are allowed by default on most
0d03aadb6c364ae976af4c904aa3625d2512d101sf platforms, but are disallowed by default on FreeBSD, NetBSD, and
0d03aadb6c364ae976af4c904aa3625d2512d101sf OpenBSD, in order to match the system-wide policy on those
0d03aadb6c364ae976af4c904aa3625d2512d101sf platforms. On systems where it is disallowed by default, a
0d03aadb6c364ae976af4c904aa3625d2512d101sf special <program>configure</program> parameter can change this behavior
0d03aadb6c364ae976af4c904aa3625d2512d101sf for Apache.</p>
0d03aadb6c364ae976af4c904aa3625d2512d101sf
0d03aadb6c364ae976af4c904aa3625d2512d101sf <p>On the other hand, on some platforms, such as Linux and Tru64, the
0d03aadb6c364ae976af4c904aa3625d2512d101sf <strong>only</strong> way to handle both IPv6 and IPv4 is to use
0d03aadb6c364ae976af4c904aa3625d2512d101sf mapped addresses. If you want Apache to handle IPv4 and IPv6 connections
0d03aadb6c364ae976af4c904aa3625d2512d101sf with a minimum of sockets, which requires using IPv4-mapped IPv6
0d03aadb6c364ae976af4c904aa3625d2512d101sf addresses, specify the <code>--enable-v4-mapped</code> <program>
0d03aadb6c364ae976af4c904aa3625d2512d101sf configure</program> option.</p>
0d03aadb6c364ae976af4c904aa3625d2512d101sf
0d03aadb6c364ae976af4c904aa3625d2512d101sf <p><code>--enable-v4-mapped</code> is the default on all platforms except
0d03aadb6c364ae976af4c904aa3625d2512d101sf FreeBSD, NetBSD, and OpenBSD, so this is probably how your Apache was
0d03aadb6c364ae976af4c904aa3625d2512d101sf built.</p>
0d03aadb6c364ae976af4c904aa3625d2512d101sf
0d03aadb6c364ae976af4c904aa3625d2512d101sf <p>If you want Apache to handle IPv4 connections only, regardless of
0d03aadb6c364ae976af4c904aa3625d2512d101sf what your platform and APR will support, specify an IPv4 address on all
0d03aadb6c364ae976af4c904aa3625d2512d101sf <directive module="mpm_common">Listen</directive> directives, as in the
0d03aadb6c364ae976af4c904aa3625d2512d101sf following examples:</p>
0d03aadb6c364ae976af4c904aa3625d2512d101sf
0d03aadb6c364ae976af4c904aa3625d2512d101sf <example>
3d27420bf1f5d019774995b66e3ba0955de6df6csf Listen 0.0.0.0:80<br />
3d27420bf1f5d019774995b66e3ba0955de6df6csf Listen 192.170.2.1:80
3d27420bf1f5d019774995b66e3ba0955de6df6csf </example>
3d27420bf1f5d019774995b66e3ba0955de6df6csf
0d03aadb6c364ae976af4c904aa3625d2512d101sf <p>If your platform supports it and you want Apache to handle IPv4 and
0d03aadb6c364ae976af4c904aa3625d2512d101sf IPv6 connections on separate sockets (i.e., to disable IPv4-mapped
0d03aadb6c364ae976af4c904aa3625d2512d101sf addresses), specify the <code>--disable-v4-mapped</code> <program>
0d03aadb6c364ae976af4c904aa3625d2512d101sf configure</program> option. <code>--disable-v4-mapped</code> is the
0d03aadb6c364ae976af4c904aa3625d2512d101sf default on FreeBSD, NetBSD, and OpenBSD.</p>
0d03aadb6c364ae976af4c904aa3625d2512d101sf </section>
0d03aadb6c364ae976af4c904aa3625d2512d101sf
0d03aadb6c364ae976af4c904aa3625d2512d101sf <section id="virtualhost">
0d03aadb6c364ae976af4c904aa3625d2512d101sf <title>How This Works With Virtual Hosts</title>
0d03aadb6c364ae976af4c904aa3625d2512d101sf
0d03aadb6c364ae976af4c904aa3625d2512d101sf <p> The <directive
0d03aadb6c364ae976af4c904aa3625d2512d101sf module="mpm_common">Listen</directive> directive does not implement
0d03aadb6c364ae976af4c904aa3625d2512d101sf Virtual Hosts - it only tells the
0d03aadb6c364ae976af4c904aa3625d2512d101sf main server what addresses and ports to listen on. If no
0d03aadb6c364ae976af4c904aa3625d2512d101sf <directive module="core" type="section">VirtualHost</directive>
0d03aadb6c364ae976af4c904aa3625d2512d101sf directives are used, the server will behave
0d03aadb6c364ae976af4c904aa3625d2512d101sf in the same way for all accepted requests. However,
0d03aadb6c364ae976af4c904aa3625d2512d101sf <directive module="core" type="section">VirtualHost</directive>
0d03aadb6c364ae976af4c904aa3625d2512d101sf can be used to specify a different behavior
0d03aadb6c364ae976af4c904aa3625d2512d101sf for one or more of the addresses or ports. To implement a
0d03aadb6c364ae976af4c904aa3625d2512d101sf VirtualHost, the server must first be told to listen to the
0d03aadb6c364ae976af4c904aa3625d2512d101sf address and port to be used. Then a
0d03aadb6c364ae976af4c904aa3625d2512d101sf <directive module="core" type="section">VirtualHost</directive> section
0d03aadb6c364ae976af4c904aa3625d2512d101sf should be created for the specified address and port to set the
0d03aadb6c364ae976af4c904aa3625d2512d101sf behavior of this virtual host. Note that if the
0d03aadb6c364ae976af4c904aa3625d2512d101sf <directive module="core" type="section">VirtualHost</directive>
is set for an address and port that the
server is not listening to, it cannot be accessed.</p>
</section>
</manualpage>