1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE manualpage SYSTEM "./style/manualpage.dtd">
3 <?xml-stylesheet type="text/xsl" href="./style/manual.en.xsl"?>
4 <!-- $Revision: 1.13 $ -->
7 Copyright 2002-2004 The Apache Software Foundation
9 Licensed under the Apache License, Version 2.0 (the "License");
10 you may not use this file except in compliance with the License.
11 You may obtain a copy of the License at
13 http://www.apache.org/licenses/LICENSE-2.0
15 Unless required by applicable law or agreed to in writing, software
16 distributed under the License is distributed on an "AS IS" BASIS,
17 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 See the License for the specific language governing permissions and
19 limitations under the License.
22 <manualpage metafile="bind.xml.meta">
24 <title>Binding</title>
27 <p>Configuring Apache to listen on specific addresses and ports.</p>
30 <seealso><a href="vhosts/">Virtual Hosts</a></seealso>
31 <seealso><a href="dns-caveats.html">DNS Issues</a></seealso>
33 <section id="overview">
34 <title>Overview</title>
39 <module>mpm_common</module>
42 <directive module="core" type="section">VirtualHost</directive>
43 <directive module="mpm_common">Listen</directive>
48 <p>When Apache starts, it binds to some port and address on
49 the local machine and waits for incoming requests. By default,
50 it listens to all addresses on the machine. However, it needs to
51 be told to listen on specific ports, or to listen on only selected
52 addresses, or a combination. This is often combined with the
53 Virtual Host feature which determines how Apache responds to
54 different IP addresses, hostnames and ports.</p>
56 <p>The <directive module="mpm_common">Listen</directive>
57 directive tells the server to accept
58 incoming requests only on the specified port or
59 address-and-port combinations. If only a port number is
60 specified in the <directive module="mpm_common">Listen</directive>
62 listens to the given port on all interfaces. If an IP address
63 is given as well as a port, the server will listen on the given
64 port and interface. Multiple <directive
65 module="mpm_common">Listen</directive> directives may be used to
66 specify a number of addresses and ports to listen on. The
67 server will respond to requests from any of the listed
68 addresses and ports.</p>
70 <p>For example, to make the server accept connections on both
71 port 80 and port 8000, use:</p>
78 <p>To make the server accept connections on two specified
79 interfaces and port numbers, use</p>
82 Listen 192.170.2.1:80<br />
83 Listen 192.170.2.5:8000
86 <p>IPv6 addresses must be surrounded in square brackets, as in the
87 following example:</p>
90 Listen [fe80::a00:20ff:fea7:ccea]:80
95 <title>Special IPv6 Considerations</title>
97 <p>A growing number of platforms implement IPv6, and APR supports
98 IPv6 on most of these platforms, allowing Apache to allocate IPv6
99 sockets and handle requests which were sent over IPv6.</p>
101 <p>One complicating factor for Apache administrators is whether or
102 not an IPv6 socket can handle both IPv4 connections and IPv6
103 connections. Handling IPv4 connections with an IPv6 socket uses
104 IPv4-mapped IPv6 addresses, which are allowed by default on most
105 platforms but are disallowed by default on FreeBSD, NetBSD, and
106 OpenBSD in order to match the system-wide policy on those
107 platforms. But even on systems where it is disallowed by default, a
108 special configure parameter can change this behavior for Apache.</p>
110 <p>On the other hand, on some platforms such as Linux and Tru64 the
111 <strong>only</strong> way to handle both IPv6 and IPv4 is to use
112 mapped addresses. If you want Apache to handle IPv4 and IPv6 connections
113 with a minimum of sockets, which requires using IPv4-mapped IPv6
114 addresses, specify the <code>--enable-v4-mapped</code> <a
115 href="programs/configure.html">configure</a> option.</p>
117 <p><code>--enable-v4-mapped</code> is the default on all platforms but
118 FreeBSD, NetBSD, and OpenBSD, so this is probably how your Apache was
121 <p>If you want Apache to handle IPv4 connections only, regardless of
122 what your platform and APR will support, specify an IPv4 address on all
123 <directive module="mpm_common">Listen</directive> directives, as in the
124 following examples:</p>
127 Listen 0.0.0.0:80<br />
128 Listen 192.170.2.1:80
131 <p>If your platform supports it and you want Apache to handle IPv4 and
132 IPv6 connections on separate sockets (i.e., to disable IPv4-mapped
133 addresses), specify the <code>--disable-v4-mapped</code> <a
134 href="programs/configure.html">configure</a> option.
135 <code>--disable-v4-mapped</code> is the default on FreeBSD,
136 NetBSD, and OpenBSD.</p>
139 <section id="virtualhost">
140 <title>How This Works With Virtual Hosts</title>
143 module="mpm_common">Listen</directive> does not implement
144 Virtual Hosts. It only tells the
145 main server what addresses and ports to listen to. If no
146 <directive module="core" type="section">VirtualHost</directive>
147 directives are used, the server will behave
148 the same for all accepted requests. However,
149 <directive module="core" type="section">VirtualHost</directive>
150 can be used to specify a different behavior
151 for one or more of the addresses and ports. To implement a
152 VirtualHost, the server must first be told to listen to the
153 address and port to be used. Then a
154 <directive module="core" type="section">VirtualHost</directive> section
155 should be created for a specified address and port to set the
156 behavior of this virtual host. Note that if the
157 <directive module="core" type="section">VirtualHost</directive>
158 is set for an address and port that the
159 server is not listening to, it cannot be accessed.</p>