]> granicus.if.org Git - apache/blob - docs/manual/bind.html.en
Add documentation for DNS issues (reliability and security), and try
[apache] / docs / manual / bind.html.en
1 <html><head>
2 <title>Setting which addresses and ports Apache uses</title>
3 </head><body>
4
5 <!--#include virtual="header.html" -->
6 <h1>Setting which addresses and ports Apache uses</h1>
7
8 <hr>
9
10 When Apache starts, it connects to some port and address on the
11 local machine and waits for incoming requests. By default, it
12 listens to all addresses on the machine, and to the port
13 as specified by the <tt>Port</tt> directive in the server configuration.
14 However, it can be told to listen to more the one port, or to listen
15 to only selected addresses, or a combination. This is often combined
16 with the Virtual Host feature which determines how Apache
17 responds to different IP addresses, hostnames and ports.<p>
18
19 There are two directives used to restrict or specify which addresses
20 and ports Apache listens to.
21
22 <ul>
23 <li><a href="#bindaddress">BindAddress</a> is used to restrict the server to listening to
24   a single address, and can be used to permit multiple Apache servers
25   on the same machine listening to different IP addresses.
26 <li><a href="#listen">Listen</a> can be used to make a single Apache server listen
27   to more than one address and/or port.
28 </ul>
29
30 <h3><a name="bindaddress">BindAddress</a></h3>
31 <strong>Syntax:</strong> BindAddress <em>[ * | IP-address | hostname ]</em><br>
32 <strong>Default:</strong> <code>BindAddress *</code><br>
33 <strong>Context:</strong> server config<br>
34 <strong>Status:</strong> Core<p>
35
36 Makes the server listen to just the specified address. If the argument
37 is *, the server listens to all addresses. The port listened to
38 is set with the <tt>Port</tt> directive. Only one BindAddress
39 should be used.
40
41 <h3><a name="listen">Listen</a></h3>
42 <strong>Syntax:</strong> Listen <em>[ port | IP-address:port ]</em><br>
43 <strong>Default:</strong> <code>none</code><br>
44 <strong>Context:</strong> server config<br>
45 <strong>Status:</strong> Core<p>
46
47 <tt>Listen</tt> can be used instead of <tt>BindAddress</tt> and
48 <tt>Port</tt>. It tells the server to accept incoming requests on the
49 specified port or address-and-port combination. If the first format is
50 used, with a port number only, the server listens to the given port on
51 all interfaces, instead of the port given by the <tt>Port</tt>
52 directive. If an IP address is given as well as a port, the server
53 will listen on the given port and interface.  <p> Multiple Listen
54 directives may be used to specify a number of addresses and ports to
55 listen to. The server will respond to requests from any of the listed
56 addresses and ports.<p>
57
58 For example, to make the server accept connections on both port
59 80 and port 8000, use:
60 <pre>
61    Listen 80
62    Listen 8000
63 </pre>
64
65 To make the server accept connections on two specified
66 interfaces and port numbers, use
67 <pre>
68    Listen 192.170.2.1:80
69    Listen 192.170.2.5:8000
70 </pre>
71
72 <h2>How this works with Virtual Hosts</h2>
73
74 BindAddress and Listen do not implement Virtual Hosts. They tell the
75 main server what addresses and ports to listen to.  If no
76 &lt;VirtualHost&gt; directives are used, the server will behave the
77 same for all accepted requests. However, &lt;VirtualHost&gt; can be
78 used to specify a different behavour for one or more of the addresses
79 and ports. To implement a VirtualHost, the server must first be told
80 to listen to the address and port to be used. Then a
81 &lt;VirtualHost&gt; section should be created for a specified address
82 and port to set the behavior of this virtual host. Note that if the
83 &lt;VirtualHost&gt; is set for an address and port that the server is
84 not listening to, it cannot be accessed.
85
86 <h2>See also</h2>
87
88 See also the documentation on
89 <a href="virtual-host.html">Virtual Hosts</a>,
90 <a href="host.html">Non-IP virtual hosts</a>,
91 <a href="mod/core.html#bindaddress">BindAddress directive</a>,
92 <a href="mod/core.html#port">Port directive</a>,
93 <a href="dns-caveats.html">DNS Issues</a>
94 and
95 <a href="mod/core.html#virtualhost">&lt;VirtualHost&gt; section</a>.
96 </ul>
97
98 <!--#include virtual="footer.html" -->
99 </BODY>
100 </HTML>
101