]> granicus.if.org Git - apache/blob - docs/manual/bind.xml
fix name of The Apache Software Foundation
[apache] / docs / manual / bind.xml
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
5 <!--
6  Copyright 2002-2004 The Apache Software Foundation
7
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
11
12      http://www.apache.org/licenses/LICENSE-2.0
13
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.
19 -->
20
21 <manualpage metafile="bind.xml.meta">
22
23   <title>Binding</title>
24
25   <summary>
26     <p>Configuring Apache to listen on specific addresses and ports.</p>
27   </summary>
28
29   <seealso><a href="vhosts/">Virtual Hosts</a></seealso>
30   <seealso><a href="dns-caveats.html">DNS Issues</a></seealso>
31
32   <section id="overview">
33     <title>Overview</title>
34
35     <related>
36       <modulelist>
37         <module>core</module>
38         <module>mpm_common</module>
39       </modulelist>
40       <directivelist>
41         <directive module="core" type="section">VirtualHost</directive>
42         <directive module="mpm_common">Listen</directive>
43       </directivelist>
44     </related>
45
46
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>
54
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>
60     directive, the server
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>
67
68     <p>For example, to make the server accept connections on both
69     port 80 and port 8000, use:</p>
70
71     <example>
72       Listen 80<br />
73       Listen 8000
74     </example>
75
76     <p>To make the server accept connections on two specified
77     interfaces and port numbers, use</p>
78
79     <example>
80       Listen 192.170.2.1:80<br />
81       Listen 192.170.2.5:8000
82     </example>
83
84     <p>IPv6 addresses must be surrounded in square brackets, as in the
85     following example:</p>
86
87     <example>
88       Listen [fe80::a00:20ff:fea7:ccea]:80
89     </example>
90   </section>
91
92   <section id="ipv6">
93     <title>Special IPv6 Considerations</title>
94
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>
98
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>
107
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 
113     option.</p>
114
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 
117     built.</p>
118
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>
122
123     <example>
124       Listen 0.0.0.0:80<br />
125       Listen 192.170.2.1:80
126     </example>
127
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>
133   </section>
134
135   <section id="virtualhost">
136     <title>How This Works With Virtual Hosts</title>
137
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>
154   </section>
155 </manualpage>
156