]> git.ipfire.org Git - thirdparty/apache/httpd.git/blob
1935961
[thirdparty/apache/httpd.git] /
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
4 <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type" />
5 <!--
6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7 This file is generated from xml source: DO NOT EDIT
8 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
9 -->
10 <title>Binding - Apache HTTP Server Version 2.2</title>
11 <link href="./style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
12 <link href="./style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
13 <link href="./style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="./style/css/prettify.css" />
14 <script src="./style/scripts/prettify.min.js" type="text/javascript">
15 </script>
16
17 <link href="./images/favicon.ico" rel="shortcut icon" /><link href="http://httpd.apache.org/docs/current/bind.html" rel="canonical" /></head>
18 <body id="manual-page"><div id="page-header">
19 <p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p>
20 <p class="apache">Apache HTTP Server Version 2.2</p>
21 <img alt="" src="./images/feather.gif" /></div>
22 <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="./images/left.gif" /></a></div>
23 <div id="path">
24 <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="./">Version 2.2</a></div><div id="page-content"><div class="retired"><h4>Please note</h4>
25 <p> This document refers to a legacy release (<strong>2.2</strong>) of Apache httpd. The active release (<strong>2.4</strong>) is documented <a href="http://httpd.apache.org/docs/current">here</a>. If you have not already upgraded, please follow <a href="http://httpd.apache.org/docs/current/upgrading.html">this link</a> for more information.</p>
26 <p>You may follow <a href="http://httpd.apache.org/docs/current/bind.html">this link</a> to go to the current version of this document.</p></div><div id="preamble"><h1>Binding</h1>
27 <div class="toplang">
28 <p><span>Available Languages: </span><a href="./de/bind.html" hreflang="de" rel="alternate" title="Deutsch">&nbsp;de&nbsp;</a> |
29 <a href="./en/bind.html" title="English">&nbsp;en&nbsp;</a> |
30 <a href="./fr/bind.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a> |
31 <a href="./ja/bind.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
32 <a href="./ko/bind.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
33 <a href="./tr/bind.html" hreflang="tr" rel="alternate" title="Türkçe">&nbsp;tr&nbsp;</a></p>
34 </div>
35
36 <p>Configuring Apache to listen on specific addresses and ports.</p>
37 </div>
38 <div id="quickview"><ul id="toc"><li><img alt="" src="./images/down.gif" /> <a href="#overview">Overview</a></li>
39 <li><img alt="" src="./images/down.gif" /> <a href="#ipv6">Special IPv6 Considerations</a></li>
40 <li><img alt="" src="./images/down.gif" /> <a href="#virtualhost">How This Works With Virtual Hosts</a></li>
41 </ul><h3>See also</h3><ul class="seealso"><li><a href="vhosts/">Virtual Hosts</a></li><li><a href="dns-caveats.html">DNS Issues</a></li></ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
42 <div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
43 <div class="section">
44 <h2><a name="overview" id="overview">Overview</a></h2>
45
46
47 <table class="related"><tr><th>Related Modules</th><th>Related Directives</th></tr><tr><td><ul><li><code class="module"><a href="./mod/core.html">core</a></code></li><li><code class="module"><a href="./mod/mpm_common.html">mpm_common</a></code></li></ul></td><td><ul><li><code class="directive"><a href="./mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code></li><li><code class="directive"><a href="./mod/mpm_common.html#listen">Listen</a></code></li></ul></td></tr></table>
48
49
50 <p>When Apache starts, it binds to some port and address on
51 the local machine and waits for incoming requests. By default,
52 it listens to all addresses on the machine. However, it may need to
53 be told to listen on specific ports, or only on selected
54 addresses, or a combination of both. This is often combined with the
55 Virtual Host feature, which determines how Apache responds to
56 different IP addresses, hostnames and ports.</p>
57
58 <p>The <code class="directive"><a href="./mod/mpm_common.html#listen">Listen</a></code>
59 directive tells the server to accept
60 incoming requests only on the specified ports or
61 address-and-port combinations. If only a port number is
62 specified in the <code class="directive"><a href="./mod/mpm_common.html#listen">Listen</a></code>
63 directive, the server
64 listens to the given port on all interfaces. If an IP address
65 is given as well as a port, the server will listen on the given
66 port and interface. Multiple <code class="directive"><a href="./mod/mpm_common.html#listen">Listen</a></code> directives may be used to
67 specify a number of addresses and ports to listen on. The
68 server will respond to requests from any of the listed
69 addresses and ports.</p>
70
71 <p>For example, to make the server accept connections on both
72 port 80 and port 8000, on all interfaces, use:</p>
73
74 <div class="example"><p><code>
75 Listen 80<br />
76 Listen 8000
77 </code></p></div>
78
79 <p>To make the server accept connections on port 80 for one interface,
80 and port 8000 on another, use</p>
81
82 <div class="example"><p><code>
83 Listen 192.0.2.1:80<br />
84 Listen 192.0.2.5:8000
85 </code></p></div>
86
87 <p>IPv6 addresses must be enclosed in square brackets, as in the
88 following example:</p>
89
90 <div class="example"><p><code>
91 Listen [2001:db8::a00:20ff:fea7:ccea]:80
92 </code></p></div>
93 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
94 <div class="section">
95 <h2><a name="ipv6" id="ipv6">Special IPv6 Considerations</a></h2>
96
97
98 <p>A growing number of platforms implement IPv6, and
99 <a class="glossarylink" href="./glossary.html#apr" title="see glossary">APR</a> supports IPv6 on most of these platforms,
100 allowing Apache to allocate IPv6 sockets, and to handle requests sent
101 over IPv6.</p>
102
103 <p>One complicating factor for Apache administrators is whether or
104 not an IPv6 socket can handle both IPv4 connections and IPv6
105 connections. Handling IPv4 connections with an IPv6 socket uses
106 IPv4-mapped IPv6 addresses, which are allowed by default on most
107 platforms, but are disallowed by default on FreeBSD, NetBSD, and
108 OpenBSD, in order to match the system-wide policy on those
109 platforms. On systems where it is disallowed by default, a
110 special <code class="program"><a href="./programs/configure.html">configure</a></code> parameter can change this behavior
111 for Apache.</p>
112
113 <p>On the other hand, on some platforms, such as Linux and Tru64, the
114 <strong>only</strong> way to handle both IPv6 and IPv4 is to use
115 mapped addresses. If you want Apache to handle IPv4 and IPv6 connections
116 with a minimum of sockets, which requires using IPv4-mapped IPv6
117 addresses, specify the <code>--enable-v4-mapped</code> <code class="program"><a href="./programs/configure.html">configure</a></code> option.</p>
118
119 <p><code>--enable-v4-mapped</code> is the default on all platforms except
120 FreeBSD, NetBSD, and OpenBSD, so this is probably how your Apache was
121 built.</p>
122
123 <p>If you want Apache to handle IPv4 connections only, regardless of
124 what your platform and APR will support, specify an IPv4 address on all
125 <code class="directive"><a href="./mod/mpm_common.html#listen">Listen</a></code> directives, as in the
126 following examples:</p>
127
128 <div class="example"><p><code>
129 Listen 0.0.0.0:80<br />
130 Listen 192.0.2.1:80
131 </code></p></div>
132
133 <p>If your platform supports it and you want Apache to handle IPv4 and
134 IPv6 connections on separate sockets (i.e., to disable IPv4-mapped
135 addresses), specify the <code>--disable-v4-mapped</code> <code class="program"><a href="./programs/configure.html">configure</a></code> option. <code>--disable-v4-mapped</code> is the
136 default on FreeBSD, NetBSD, and OpenBSD.</p>
137 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
138 <div class="section">
139 <h2><a name="virtualhost" id="virtualhost">How This Works With Virtual Hosts</a></h2>
140
141
142 <p> The <code class="directive"><a href="./mod/mpm_common.html#listen">Listen</a></code> directive does not implement
143 Virtual Hosts - it only tells the
144 main server what addresses and ports to listen on. If no
145 <code class="directive"><a href="./mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code>
146 directives are used, the server will behave
147 in the same way for all accepted requests. However,
148 <code class="directive"><a href="./mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code>
149 can be used to specify a different behavior
150 for one or more of the addresses or ports. To implement a
151 VirtualHost, the server must first be told to listen to the
152 address and port to be used. Then a
153 <code class="directive"><a href="./mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code> section
154 should be created for the specified address and port to set the
155 behavior of this virtual host. Note that if the
156 <code class="directive"><a href="./mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code>
157 is set for an address and port that the
158 server is not listening to, it cannot be accessed.</p>
159 </div></div>
160 <div class="bottomlang">
161 <p><span>Available Languages: </span><a href="./de/bind.html" hreflang="de" rel="alternate" title="Deutsch">&nbsp;de&nbsp;</a> |
162 <a href="./en/bind.html" title="English">&nbsp;en&nbsp;</a> |
163 <a href="./fr/bind.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a> |
164 <a href="./ja/bind.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
165 <a href="./ko/bind.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
166 <a href="./tr/bind.html" hreflang="tr" rel="alternate" title="Türkçe">&nbsp;tr&nbsp;</a></p>
167 </div><div class="top"><a href="#page-header"><img src="./images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
168 <script type="text/javascript"><!--//--><![CDATA[//><!--
169 var comments_shortname = 'httpd';
170 var comments_identifier = 'http://httpd.apache.org/docs/2.2/bind.html';
171 (function(w, d) {
172 if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
173 d.write('<div id="comments_thread"><\/div>');
174 var s = d.createElement('script');
175 s.type = 'text/javascript';
176 s.async = true;
177 s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
178 (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
179 }
180 else {
181 d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
182 }
183 })(window, document);
184 //--><!]]></script></div><div id="footer">
185 <p class="apache">Copyright 2017 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
186 <p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
187 if (typeof(prettyPrint) !== 'undefined') {
188 prettyPrint();
189 }
190 //--><!]]></script>
191 </body></html>