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 <relativepath href="."/>
11 <p>Configuring Apache to listen on specific addresses and ports.</p>
14 <seealso><a href="vhosts/">Virtual Hosts</a></seealso>
15 <seealso><a href="dns-caveats.html">DNS Issues</a></seealso>
17 <section id="overview">
18 <title>Overview</title>
23 <module>mpm_common</module>
26 <directive module="core">VirtualHost</directive>
27 <directive module="mpm_common">Listen</directive>
32 <p>When Apache starts, it binds to some port and address on
33 the local machine and waits for incoming requests. By default,
34 it listens to all addresses on the machine. However, it needs to
35 be told to listen on specific ports, or to listen on only selected
36 addresses, or a combination. This is often combined with the
37 Virtual Host feature which determines how Apache responds to
38 different IP addresses, hostnames and ports.</p>
40 <p>The <directive module="mpm_common">Listen</directive>
41 directive tells the server to accept
42 incoming requests only on the specified port or
43 address-and-port combinations. If only a port number is
44 specified in the <directive module="mpm_common">Listen</directive>
46 listens to the given port on all interfaces. If an IP address
47 is given as well as a port, the server will listen on the given
48 port and interface. Multiple Listen directives may be used to
49 specify a number of addresses and ports to listen on. The
50 server will respond to requests from any of the listed
51 addresses and ports.</p>
53 <p>For example, to make the server accept connections on both
54 port 80 and port 8000, use:</p>
61 <p>To make the server accept connections on two specified
62 interfaces and port numbers, use</p>
65 Listen 192.170.2.1:80<br />
66 Listen 192.170.2.5:8000
69 <p>IPv6 addresses must be surrounded in square brackets, as in the
70 following example:</p>
73 Listen [fe80::a00:20ff:fea7:ccea]:80
78 <title>Special IPv6 Considerations</title>
80 <p>When APR supports IPv6, Apache will create IPv6-capable listening
81 sockets by default (i.e., when no IP address is specified on the
82 Listen directive). In other words, when APR supports IPv6,</p>
88 <p>is equivalent to</p>
94 <p>When APR does not support IPv6,</p>
100 <p>is equivalent to</p>
106 <p>On some platforms, such as NetBSD, binding to the IPv6 wildcard address
107 ("::") does not allow Apache to accept connections on IPv4 interfaces.
108 In this situation, multiple Listen directives are required, as shown
112 Listen 0.0.0.0:80<br />
116 <p>Apache does not currently detect this, so the Listen statements must
117 be edited manually by the administrator.</p>
120 <section id="virtualhost">
121 <title>How This Works With Virtual Hosts</title>
123 <p>Listen does not implement Virtual Hosts. It only tells the
124 main server what addresses and ports to listen to. If no
125 <directive module="core" type="section">VirtualHost</directive>
126 directives are used, the server will behave
127 the same for all accepted requests. However,
128 <directive module="core" type="section">VirtualHost</directive>
129 can be used to specify a different behavior
130 for one or more of the addresses and ports. To implement a
131 VirtualHost, the server must first be told to listen to the
132 address and port to be used. Then a
133 <directive module="core" type="section">VirtualHost</directive> section
134 should be created for a specified address and port to set the
135 behavior of this virtual host. Note that if the
136 <directive module="core" type="section">VirtualHost</directive>
137 is set for an address and port that the
138 server is not listening to, it cannot be accessed.</p>