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"?>
6 Copyright 2002-2004 The Apache Software Foundation
8 Licensed under the Apache License, Version 2.0 (the "License");
9 you may not use this file except in compliance with the License.
10 You may obtain a copy of the License at
12 http://www.apache.org/licenses/LICENSE-2.0
14 Unless required by applicable law or agreed to in writing, software
15 distributed under the License is distributed on an "AS IS" BASIS,
16 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 See the License for the specific language governing permissions and
18 limitations under the License.
21 <manualpage metafile="bind.xml.meta">
23 <title>Binding</title>
26 <p>Configuring Apache to listen on specific addresses and ports.</p>
29 <seealso><a href="vhosts/">Virtual Hosts</a></seealso>
30 <seealso><a href="dns-caveats.html">DNS Issues</a></seealso>
32 <section id="overview">
33 <title>Overview</title>
38 <module>mpm_common</module>
41 <directive module="core" type="section">VirtualHost</directive>
42 <directive module="mpm_common">Listen</directive>
47 <p>When Apache starts, it binds to some port and address on
48 the local machine and waits for incoming requests. By default,
49 it listens to all addresses on the machine. However, it needs to
50 be told to listen on specific ports, or to listen on only selected
51 addresses, or a combination. This is often combined with the
52 Virtual Host feature which determines how Apache responds to
53 different IP addresses, hostnames and ports.</p>
55 <p>The <directive module="mpm_common">Listen</directive>
56 directive tells the server to accept
57 incoming requests only on the specified port or
58 address-and-port combinations. If only a port number is
59 specified in the <directive module="mpm_common">Listen</directive>
61 listens to the given port on all interfaces. If an IP address
62 is given as well as a port, the server will listen on the given
63 port and interface. Multiple Listen directives may be used to
64 specify a number of addresses and ports to listen on. The
65 server will respond to requests from any of the listed
66 addresses and ports.</p>
68 <p>For example, to make the server accept connections on both
69 port 80 and port 8000, use:</p>
76 <p>To make the server accept connections on two specified
77 interfaces and port numbers, use</p>
80 Listen 192.170.2.1:80<br />
81 Listen 192.170.2.5:8000
84 <p>IPv6 addresses must be surrounded in square brackets, as in the
85 following example:</p>
88 Listen [fe80::a00:20ff:fea7:ccea]:80
93 <title>Special IPv6 Considerations</title>
95 <p>A growing number of platforms implement IPv6, and APR supports
96 IPv6 on most of these platforms, allowing Apache to allocate IPv6
97 sockets and handle requests which were sent over IPv6.</p>
99 <p>One complicating factor for Apache administrators is whether or
100 not an IPv6 socket can handle both IPv4 connections and IPv6
101 connections. Handling IPv4 connections with an IPv6 socket uses
102 IPv4-mapped IPv6 addresses, which are allowed by default on most
103 platforms but are disallowed by default on FreeBSD, NetBSD, and
104 OpenBSD in order to match the system-wide policy on those
105 platforms. But even on systems where it is disallowed by default, a
106 special configure parameter can change this behavior for Apache.</p>
108 <p>On the other hand, on some platforms such as Linux and Tru64 the
109 <strong>only</strong> way to handle both IPv6 and IPv4 is to use
110 mapped addresses. If you want Apache to handle IPv4 and IPv6 connections
111 with a minimum of sockets, which requires using IPv4-mapped IPv6
112 addresses, specify the <code>--enable-v4-mapped</code> configure
115 <p><code>--enable-v4-mapped</code> is the default on all platforms but
116 FreeBSD, NetBSD, and OpenBSD, so this is probably how your Apache was
119 <p>If you want Apache to handle IPv4 connections only, regardless of
120 what your platform and APR will support, specify an IPv4 address on all
121 Listen directives, as in the following examples:</p>
124 Listen 0.0.0.0:80<br />
125 Listen 192.170.2.1:80
128 <p>If your platform supports it and you want Apache to handle IPv4 and
129 IPv6 connections on separate sockets (i.e., to disable IPv4-mapped
130 addresses), specify the <code>--disable-v4-mapped</code> configure
131 option. <code>--disable-v4-mapped</code> is the default on FreeBSD,
132 NetBSD, and OpenBSD.</p>
135 <section id="virtualhost">
136 <title>How This Works With Virtual Hosts</title>
138 <p>Listen does not implement Virtual Hosts. It only tells the
139 main server what addresses and ports to listen to. If no
140 <directive module="core" type="section">VirtualHost</directive>
141 directives are used, the server will behave
142 the same for all accepted requests. However,
143 <directive module="core" type="section">VirtualHost</directive>
144 can be used to specify a different behavior
145 for one or more of the addresses and ports. To implement a
146 VirtualHost, the server must first be told to listen to the
147 address and port to be used. Then a
148 <directive module="core" type="section">VirtualHost</directive> section
149 should be created for a specified address and port to set the
150 behavior of this virtual host. Note that if the
151 <directive module="core" type="section">VirtualHost</directive>
152 is set for an address and port that the
153 server is not listening to, it cannot be accessed.</p>