]> granicus.if.org Git - apache/blob - docs/manual/bind.html
Another pass at the normalisation of the HTML tags. Some
[apache] / docs / manual / bind.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2 <HTML><HEAD>
3 <TITLE>Setting which addresses and ports Apache uses</TITLE>
4 </HEAD>
5
6 <!-- Background white, links blue (unvisited), navy (visited), red (active) -->
7 <BODY
8  BGCOLOR="#FFFFFF"
9  TEXT="#000000"
10  LINK="#0000FF"
11  VLINK="#000080"
12  ALINK="#FF0000"
13 >
14 <!--#include virtual="header.html" -->
15 <H1 ALIGN="CENTER">Setting which addresses and ports Apache uses</H1>
16
17 <HR>
18
19 When Apache starts, it connects to some port and address on the
20 local machine and waits for incoming requests. By default, it
21 listens to all addresses on the machine, and to the port
22 as specified by the <TT>Port</TT> directive in the server configuration.
23 However, it can be told to listen to more the one port, or to listen
24 to only selected addresses, or a combination. This is often combined
25 with the Virtual Host feature which determines how Apache
26 responds to different IP addresses, hostnames and ports.<P>
27
28 There are two directives used to restrict or specify which addresses
29 and ports Apache listens to.
30
31 <UL>
32 <LI><A HREF="#bindaddress">BindAddress</A> is used to restrict the server to listening to
33   a single address, and can be used to permit multiple Apache servers
34   on the same machine listening to different IP addresses.
35 <LI><A HREF="#listen">Listen</A> can be used to make a single Apache server listen
36   to more than one address and/or port.
37 </UL>
38
39 <H3><A name="bindaddress">BindAddress</A></H3>
40 <A
41  HREF="directive-dict.html#Syntax"
42  REL="Help"
43 ><STRONG>Syntax:</STRONG></A> BindAddress <EM>[ * | IP-address | hostname ]</EM><BR>
44 <A
45  HREF="directive-dict.html#Default"
46  REL="Help"
47 ><STRONG>Default:</STRONG></A> <CODE>BindAddress *</CODE><BR>
48 <A
49  HREF="directive-dict.html#Context"
50  REL="Help"
51 ><STRONG>Context:</STRONG></A> server config<BR>
52 <A
53  HREF="directive-dict.html#Status"
54  REL="Help"
55 ><STRONG>Status:</STRONG></A> Core<P>
56
57 Makes the server listen to just the specified address. If the argument
58 is *, the server listens to all addresses. The port listened to
59 is set with the <TT>Port</TT> directive. Only one BindAddress
60 should be used.
61
62 <H3><A name="listen">Listen</A></H3>
63 <A
64  HREF="directive-dict.html#Syntax"
65  REL="Help"
66 ><STRONG>Syntax:</STRONG></A> Listen <EM>[ port | IP-address:port ]</EM><BR>
67 <A
68  HREF="directive-dict.html#Default"
69  REL="Help"
70 ><STRONG>Default:</STRONG></A> <CODE>none</CODE><BR>
71 <A
72  HREF="directive-dict.html#Context"
73  REL="Help"
74 ><STRONG>Context:</STRONG></A> server config<BR>
75 <A
76  HREF="directive-dict.html#Status"
77  REL="Help"
78 ><STRONG>Status:</STRONG></A> Core<P>
79
80 <TT>Listen</TT> can be used instead of <TT>BindAddress</TT> and
81 <TT>Port</TT>. It tells the server to accept incoming requests on the
82 specified port or address-and-port combination. If the first format is
83 used, with a port number only, the server listens to the given port on
84 all interfaces, instead of the port given by the <TT>Port</TT>
85 directive. If an IP address is given as well as a port, the server
86 will listen on the given port and interface.  <P> Multiple Listen
87 directives may be used to specify a number of addresses and ports to
88 listen to. The server will respond to requests from any of the listed
89 addresses and ports.<P>
90
91 For example, to make the server accept connections on both port
92 80 and port 8000, use:
93 <PRE>
94    Listen 80
95    Listen 8000
96 </PRE>
97
98 To make the server accept connections on two specified
99 interfaces and port numbers, use
100 <PRE>
101    Listen 192.170.2.1:80
102    Listen 192.170.2.5:8000
103 </PRE>
104
105 <H2>How this works with Virtual Hosts</H2>
106
107 BindAddress and Listen do not implement Virtual Hosts. They tell the
108 main server what addresses and ports to listen to.  If no
109 &lt;VirtualHost&gt; directives are used, the server will behave the
110 same for all accepted requests. However, &lt;VirtualHost&gt; can be
111 used to specify a different behavior for one or more of the addresses
112 and ports. To implement a VirtualHost, the server must first be told
113 to listen to the address and port to be used. Then a
114 &lt;VirtualHost&gt; section should be created for a specified address
115 and port to set the behavior of this virtual host. Note that if the
116 &lt;VirtualHost&gt; is set for an address and port that the server is
117 not listening to, it cannot be accessed.
118
119 <H2>See also</H2>
120
121 See also the documentation on
122 <A HREF="vhosts/index.html">Virtual Hosts</A>,
123 <A HREF="mod/core.html#bindaddress">BindAddress directive</A>,
124 <A HREF="mod/core.html#port">Port directive</A>,
125 <A HREF="dns-caveats.html">DNS Issues</A>
126 and
127 <A HREF="mod/core.html#virtualhost">&lt;VirtualHost&gt; section</A>.
128
129 <!--#include virtual="footer.html" -->
130 </BODY>
131 </HTML>
132