]> granicus.if.org Git - apache/blob - docs/manual/bind.html.en
ie40 screws up vary
[apache] / docs / manual / bind.html.en
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
33   listening to
34   a single address, and can be used to permit multiple Apache servers
35   on the same machine listening to different IP addresses.
36 <LI><A HREF="#listen">Listen</A> can be used to make a single Apache server
37   listen
38   to more than one address and/or port.
39 </UL>
40
41 <H3><A NAME="bindaddress">BindAddress</A></H3>
42 <A
43  HREF="mod/directive-dict.html#Syntax"
44  REL="Help"
45 ><STRONG>Syntax:</STRONG></A> BindAddress <EM>[ * | IP-address 
46  | hostname ]</EM><BR>
47 <A
48  HREF="mod/directive-dict.html#Default"
49  REL="Help"
50 ><STRONG>Default:</STRONG></A> <CODE>BindAddress *</CODE><BR>
51 <A
52  HREF="mod/directive-dict.html#Context"
53  REL="Help"
54 ><STRONG>Context:</STRONG></A> server config<BR>
55 <A
56  HREF="mod/directive-dict.html#Status"
57  REL="Help"
58 ><STRONG>Status:</STRONG></A> Core<P>
59
60 Makes the server listen to just the specified address. If the argument
61 is *, the server listens to all addresses. The port listened to
62 is set with the <TT>Port</TT> directive. Only one BindAddress
63 should be used.
64
65 <H3><A NAME="listen">Listen</A></H3>
66 <A
67  HREF="mod/directive-dict.html#Syntax"
68  REL="Help"
69 ><STRONG>Syntax:</STRONG></A> Listen <EM>[ port | IP-address:port ]</EM><BR>
70 <A
71  HREF="mod/directive-dict.html#Default"
72  REL="Help"
73 ><STRONG>Default:</STRONG></A> <CODE>none</CODE><BR>
74 <A
75  HREF="mod/directive-dict.html#Context"
76  REL="Help"
77 ><STRONG>Context:</STRONG></A> server config<BR>
78 <A
79  HREF="mod/directive-dict.html#Status"
80  REL="Help"
81 ><STRONG>Status:</STRONG></A> Core<P>
82
83 <TT>Listen</TT> can be used instead of <TT>BindAddress</TT> and
84 <TT>Port</TT>. It tells the server to accept incoming requests on the
85 specified port or address-and-port combination. If the first format is
86 used, with a port number only, the server listens to the given port on
87 all interfaces, instead of the port given by the <TT>Port</TT>
88 directive. If an IP address is given as well as a port, the server
89 will listen on the given port and interface.  <P> Multiple Listen
90 directives may be used to specify a number of addresses and ports to
91 listen to. The server will respond to requests from any of the listed
92 addresses and ports.<P>
93
94 For example, to make the server accept connections on both port
95 80 and port 8000, use:
96 <PRE>
97    Listen 80
98    Listen 8000
99 </PRE>
100
101 To make the server accept connections on two specified
102 interfaces and port numbers, use
103 <PRE>
104    Listen 192.170.2.1:80
105    Listen 192.170.2.5:8000
106 </PRE>
107
108 <H2>How this works with Virtual Hosts</H2>
109
110 BindAddress and Listen do not implement Virtual Hosts. They tell the
111 main server what addresses and ports to listen to.  If no
112 &lt;VirtualHost&gt; directives are used, the server will behave the
113 same for all accepted requests. However, &lt;VirtualHost&gt; can be
114 used to specify a different behavior for one or more of the addresses
115 and ports. To implement a VirtualHost, the server must first be told
116 to listen to the address and port to be used. Then a
117 &lt;VirtualHost&gt; section should be created for a specified address
118 and port to set the behavior of this virtual host. Note that if the
119 &lt;VirtualHost&gt; is set for an address and port that the server is
120 not listening to, it cannot be accessed.
121
122 <H2>See also</H2>
123
124 See also the documentation on
125 <A HREF="vhosts/index.html">Virtual Hosts</A>,
126 <A HREF="mod/core.html#bindaddress">BindAddress directive</A>,
127 <A HREF="mod/core.html#port">Port directive</A>,
128 <A HREF="dns-caveats.html">DNS Issues</A>
129 and
130 <A HREF="mod/core.html#virtualhost">&lt;VirtualHost&gt; section</A>.
131
132 <!--#include virtual="footer.html" -->
133 </BODY>
134 </HTML>
135