1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
6<html xmlns="http://www.w3.org/1999/xhtml">
7  <head>
8    <meta name="generator" content="HTML Tidy, see www.w3.org" />
9
10    <title>Setting which addresses and ports Apache uses</title>
11  </head>
12  <!-- Background white, links blue (unvisited), navy (visited), red (active) -->
13
14  <body bgcolor="#FFFFFF" text="#000000" link="#0000FF"
15  vlink="#000080" alink="#FF0000">
16        <div align="CENTER">
17      <img src="images/sub.gif" alt="[APACHE DOCUMENTATION]" />
18
19      <h3>Apache HTTP Server</h3>
20    </div>
21
22
23
24    <h1 align="CENTER">Setting which addresses and ports Apache
25    uses</h1>
26    <hr />
27    When Apache starts, it connects to some port and address on the
28    local machine and waits for incoming requests. By default, it
29    listens to all addresses on the machine, and to the port as
30    specified by the <tt>Port</tt> directive in the server
31    configuration. However, it can be told to listen to more the
32    one port, or to listen to only selected addresses, or a
33    combination. This is often combined with the Virtual Host
34    feature which determines how Apache responds to different IP
35    addresses, hostnames and ports.
36
37    <p>There are two directives used to restrict or specify which
38    addresses and ports Apache listens to.</p>
39
40    <ul>
41      <li><a href="#bindaddress">BindAddress</a> is used to
42      restrict the server to listening to a single address, and can
43      be used to permit multiple Apache servers on the same machine
44      listening to different IP addresses.</li>
45
46      <li><a href="#listen">Listen</a> can be used to make a single
47      Apache server listen to more than one address and/or
48      port.</li>
49    </ul>
50
51    <h3><a id="bindaddress" name="bindaddress">BindAddress</a></h3>
52    <a href="mod/directive-dict.html#Syntax"
53    rel="Help"><strong>Syntax:</strong></a> BindAddress <em>[ * |
54    IP-address | hostname ]</em><br />
55     <a href="mod/directive-dict.html#Default"
56    rel="Help"><strong>Default:</strong></a> <code>BindAddress
57    *</code><br />
58     <a href="mod/directive-dict.html#Context"
59    rel="Help"><strong>Context:</strong></a> server config<br />
60     <a href="mod/directive-dict.html#Status"
61    rel="Help"><strong>Status:</strong></a> Core
62
63    <p>Makes the server bind to just the specified address. If the
64    argument is * (an asterisk), the server binds to all interfaces
65    currently marked as up on the server. The port bound to is set
66    with the <tt>Port</tt> directive. Only one BindAddress should
67    be used.</p>
68
69    <h3><a id="listen" name="listen">Listen</a></h3>
70    <a href="mod/directive-dict.html#Syntax"
71    rel="Help"><strong>Syntax:</strong></a> Listen <em>[ port |
72    IP-address:port ]</em><br />
73     <a href="mod/directive-dict.html#Default"
74    rel="Help"><strong>Default:</strong></a>
75    <code>none</code><br />
76     <a href="mod/directive-dict.html#Context"
77    rel="Help"><strong>Context:</strong></a> server config<br />
78     <a href="mod/directive-dict.html#Status"
79    rel="Help"><strong>Status:</strong></a> Core
80
81    <p><tt>Listen</tt> can be used instead of <tt>BindAddress</tt>
82    and <tt>Port</tt>. It tells the server to accept incoming
83    requests (to listen) on the specified port or address-and-port
84    combination. If the first format is used, with a port number
85    only, the server listens on the given port on all interfaces
86    marked as up, instead of the port given by the <tt>Port</tt>
87    directive. If an IP address is given as well as a port, the
88    server will listen on the given port and interface.</p>
89
90    <p>Multiple Listen directives may be used to specify a number
91    of addresses and ports to listen to. The server will respond to
92    requests from any of the listed addresses and ports.</p>
93
94    <p>For example, to make the server accept connections on both
95    port 80 and port 8000, use:</p>
96<pre>
97   Listen 80
98   Listen 8000
99</pre>
100    To make the server accept connections on two specified
101    interfaces and port numbers, use
102<pre>
103   Listen 192.170.2.1:80
104   Listen 192.170.2.5:8000
105</pre>
106
107    <h2>How this works with Virtual Hosts</h2>
108    <tt>BindAddress</tt> and <tt>Listen</tt> do not implement
109    Virtual Hosts. They tell the main Apache daemon process what
110    addresses and ports to bind and listen on. If no
111    &lt;VirtualHost&gt; directives are used, the server will behave
112    the same for all accepted requests. However,
113    &lt;VirtualHost&gt; can be used to specify a different behavior
114    for one or more of the addresses and ports. To implement a
115    VirtualHost, the server must:
116
117    <ul>
118      <li>Be told to <tt>Listen</tt> to the desired address and
119      port</li>
120
121      <li>Have a &lt;VirtualHost&gt; section created for the
122      specified address and port to set the behavior of this
123      virtual host</li>
124    </ul>
125    Note that if the &lt;VirtualHost&gt; is set for an address and
126    port that the server is not listening to, it cannot be
127    accessed.
128
129    <h2>See also</h2>
130    See also the documentation on <a href="vhosts/">Virtual
131    Hosts</a>, <a href="mod/core.html#bindaddress">BindAddress
132    directive</a>, <a href="mod/core.html#port">Port directive</a>,
133    <a href="dns-caveats.html">DNS Issues</a> and <a
134    href="mod/core.html#virtualhost">&lt;VirtualHost&gt;
135    section</a>.     <hr />
136
137    <h3 align="CENTER">Apache HTTP Server</h3>
138    <a href="./"><img src="images/index.gif" alt="Index" /></a>
139
140  </body>
141</html>
142
143
144
145