bind.xml revision b4600e71d7e8201b3c14c67f4ef873cadd4c1d17
a23fd118e437af0a7877dd313db8fdaa3537c675yl<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
a23fd118e437af0a7877dd313db8fdaa3537c675yl<manualpage>
a23fd118e437af0a7877dd313db8fdaa3537c675yl <p>Configuring Apache to listen on specific addresses and ports.</p>
a23fd118e437af0a7877dd313db8fdaa3537c675yl </summary>
a23fd118e437af0a7877dd313db8fdaa3537c675yl <seealso><a href="dns-caveats.html">DNS Issues</a></seealso>
a23fd118e437af0a7877dd313db8fdaa3537c675yl <modulelist>
a23fd118e437af0a7877dd313db8fdaa3537c675yl </modulelist>
a23fd118e437af0a7877dd313db8fdaa3537c675yl <directivelist>
a23fd118e437af0a7877dd313db8fdaa3537c675yl </directivelist>
a23fd118e437af0a7877dd313db8fdaa3537c675yl </related>
a23fd118e437af0a7877dd313db8fdaa3537c675yl <p>When Apache starts, it binds to some port and address on
a23fd118e437af0a7877dd313db8fdaa3537c675yl the local machine and waits for incoming requests. By default,
a23fd118e437af0a7877dd313db8fdaa3537c675yl it listens to all addresses on the machine. However, it needs to
a23fd118e437af0a7877dd313db8fdaa3537c675yl be told to listen on specific ports, or to listen on only selected
a23fd118e437af0a7877dd313db8fdaa3537c675yl addresses, or a combination. This is often combined with the
a23fd118e437af0a7877dd313db8fdaa3537c675yl Virtual Host feature which determines how Apache responds to
a23fd118e437af0a7877dd313db8fdaa3537c675yl different IP addresses, hostnames and ports.</p>
a23fd118e437af0a7877dd313db8fdaa3537c675yl directive tells the server to accept
a23fd118e437af0a7877dd313db8fdaa3537c675yl incoming requests only on the specified port or
a23fd118e437af0a7877dd313db8fdaa3537c675yl address-and-port combinations. If only a port number is
a23fd118e437af0a7877dd313db8fdaa3537c675yl specified in the <directive module="mpm_common">Listen</directive>
a23fd118e437af0a7877dd313db8fdaa3537c675yl directive, the server
a23fd118e437af0a7877dd313db8fdaa3537c675yl listens to the given port on all interfaces. If an IP address
a23fd118e437af0a7877dd313db8fdaa3537c675yl is given as well as a port, the server will listen on the given
a23fd118e437af0a7877dd313db8fdaa3537c675yl port and interface. Multiple Listen directives may be used to
a23fd118e437af0a7877dd313db8fdaa3537c675yl specify a number of addresses and ports to listen on. The
a23fd118e437af0a7877dd313db8fdaa3537c675yl server will respond to requests from any of the listed
a23fd118e437af0a7877dd313db8fdaa3537c675yl addresses and ports.</p>
a23fd118e437af0a7877dd313db8fdaa3537c675yl <p>For example, to make the server accept connections on both
a23fd118e437af0a7877dd313db8fdaa3537c675yl port 80 and port 8000, use:</p>
a23fd118e437af0a7877dd313db8fdaa3537c675yl Listen 80<br />
a23fd118e437af0a7877dd313db8fdaa3537c675yl Listen 8000
a23fd118e437af0a7877dd313db8fdaa3537c675yl </example>
a23fd118e437af0a7877dd313db8fdaa3537c675yl <p>To make the server accept connections on two specified
a23fd118e437af0a7877dd313db8fdaa3537c675yl interfaces and port numbers, use</p>
a23fd118e437af0a7877dd313db8fdaa3537c675yl Listen 192.170.2.1:80<br />
a23fd118e437af0a7877dd313db8fdaa3537c675yl Listen 192.170.2.5:8000
a23fd118e437af0a7877dd313db8fdaa3537c675yl </example>
a23fd118e437af0a7877dd313db8fdaa3537c675yl <p>IPv6 addresses must be surrounded in square brackets, as in the
a23fd118e437af0a7877dd313db8fdaa3537c675yl following example:</p>
a23fd118e437af0a7877dd313db8fdaa3537c675yl Listen [fe80::a00:20ff:fea7:ccea]:80
a23fd118e437af0a7877dd313db8fdaa3537c675yl </example>
a23fd118e437af0a7877dd313db8fdaa3537c675yl </section>
a23fd118e437af0a7877dd313db8fdaa3537c675yl <p>A growing number of platforms implement IPv6, and APR supports
a23fd118e437af0a7877dd313db8fdaa3537c675yl IPv6 on most of these platforms, allowing Apache to allocate IPv6
a23fd118e437af0a7877dd313db8fdaa3537c675yl sockets and handle requests which were sent over IPv6.</p>
a23fd118e437af0a7877dd313db8fdaa3537c675yl <p>One complicating factor for Apache administrators is whether or
a23fd118e437af0a7877dd313db8fdaa3537c675yl not an IPv6 socket can handle both IPv4 connections and IPv6
a23fd118e437af0a7877dd313db8fdaa3537c675yl connections. Handling IPv4 connections with an IPv6 socket uses
a23fd118e437af0a7877dd313db8fdaa3537c675yl IPv4-mapped IPv6 addresses, which are allowed by default on most
8347601bcb0a439f6e50fc36b4039a73d08700e1yl platforms but are disallowed by default on FreeBSD, NetBSD, and
8347601bcb0a439f6e50fc36b4039a73d08700e1yl OpenBSD in order to match the system-wide policy on those
a23fd118e437af0a7877dd313db8fdaa3537c675yl platforms. But even on systems where it is disallowed by default, a
a23fd118e437af0a7877dd313db8fdaa3537c675yl special configure parameter can change this behavior for Apache.</p>
a23fd118e437af0a7877dd313db8fdaa3537c675yl <p>If you want Apache to handle IPv4 and IPv6 connections with a
a23fd118e437af0a7877dd313db8fdaa3537c675yl minimum of sockets, which requires using IPv4-mapped IPv6 addresses,
a23fd118e437af0a7877dd313db8fdaa3537c675yl specify the <code>--enable-v4-mapped</code> configure option and use
a23fd118e437af0a7877dd313db8fdaa3537c675yl generic Listen directives like the following:</p>
bb25c06cca41ca78e5fb87fbb8e81d55beb18c95jg </example>
bb25c06cca41ca78e5fb87fbb8e81d55beb18c95jg <p>With <code>--enable-v4-mapped</code>, the Listen directives in the
bb25c06cca41ca78e5fb87fbb8e81d55beb18c95jg default configuration file created by Apache will use this form.
bb25c06cca41ca78e5fb87fbb8e81d55beb18c95jg <code>--enable-v4-mapped</code> is the default on all platforms but
bb25c06cca41ca78e5fb87fbb8e81d55beb18c95jg FreeBSD, NetBSD, and OpenBSD, so this is probably how your Apache was
bb25c06cca41ca78e5fb87fbb8e81d55beb18c95jg built.</p>
bb25c06cca41ca78e5fb87fbb8e81d55beb18c95jg <p>If you want Apache to handle IPv4 connections only, regardless of
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe what your platform and APR will support, specify an IPv4 address on all
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe Listen directives, as in the following examples:</p>
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe Listen 0.0.0.0:80<br />
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe Listen 192.170.2.1:80
a23fd118e437af0a7877dd313db8fdaa3537c675yl </example>
a23fd118e437af0a7877dd313db8fdaa3537c675yl <p>If you want Apache to handle IPv4 and IPv6 connections on separate
a23fd118e437af0a7877dd313db8fdaa3537c675yl sockets (i.e., to disable IPv4-mapped addresses), specify the
a23fd118e437af0a7877dd313db8fdaa3537c675yl <code>--disable-v4-mapped</code> configure option and use specific Listen
a23fd118e437af0a7877dd313db8fdaa3537c675yl directives like the following:</p>
a23fd118e437af0a7877dd313db8fdaa3537c675yl Listen [::]:80<br />
a23fd118e437af0a7877dd313db8fdaa3537c675yl Listen 0.0.0.0:80
a23fd118e437af0a7877dd313db8fdaa3537c675yl </example>
a23fd118e437af0a7877dd313db8fdaa3537c675yl <p>With <code>--disable-v4-mapped</code>, the Listen directives in the
a23fd118e437af0a7877dd313db8fdaa3537c675yl default configuration file created by Apache will use this form.
a23fd118e437af0a7877dd313db8fdaa3537c675yl <code>--disable-v4-mapped</code> is the default on FreeBSD, NetBSD, and
a23fd118e437af0a7877dd313db8fdaa3537c675yl OpenBSD.</p>
a23fd118e437af0a7877dd313db8fdaa3537c675yl </section>
a23fd118e437af0a7877dd313db8fdaa3537c675yl <p>Listen does not implement Virtual Hosts. It only tells the
a23fd118e437af0a7877dd313db8fdaa3537c675yl main server what addresses and ports to listen to. If no
a23fd118e437af0a7877dd313db8fdaa3537c675yl <directive module="core" type="section">VirtualHost</directive>
a23fd118e437af0a7877dd313db8fdaa3537c675yl directives are used, the server will behave