bind.html revision f9b3be308809978f797e0c57b296147532a4313c
299N/A<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
299N/A<HTML><HEAD>
299N/A<TITLE>Setting which addresses and ports Apache uses</TITLE>
299N/A</HEAD>
299N/A
299N/A<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
299N/A<BODY
299N/A BGCOLOR="#FFFFFF"
299N/A TEXT="#000000"
299N/A LINK="#0000FF"
299N/A VLINK="#000080"
299N/A ALINK="#FF0000"
299N/A>
299N/A<!--#include virtual="header.html" -->
299N/A<h1 ALIGN="CENTER">Setting which addresses and ports Apache uses</H1>
299N/A
299N/A<HR>
299N/A
873N/AWhen Apache starts, it connects to some port and address on the
299N/Alocal machine and waits for incoming requests. By default, it
299N/Alistens to all addresses on the machine, and to the port
299N/Aas specified by the <TT>Port</TT> directive in the server configuration.
299N/AHowever, it can be told to listen to more the one port, or to listen
299N/Ato only selected addresses, or a combination. This is often combined
3232N/Awith the Virtual Host feature which determines how Apache
299N/Aresponds to different IP addresses, hostnames and ports.<P>
299N/A
299N/AThere are two directives used to restrict or specify which addresses
1242N/Aand ports Apache listens to.
2334N/A
2334N/A<UL>
299N/A<LI><A HREF="#bindaddress">BindAddress</A> is used to restrict the server to listening to
299N/A a single address, and can be used to permit multiple Apache servers
299N/A on the same machine listening to different IP addresses.
299N/A<LI><A HREF="#listen">Listen</A> can be used to make a single Apache server listen
299N/A to more than one address and/or port.
299N/A</UL>
299N/A
299N/A<h3><A name="bindaddress">BindAddress</A></h3>
299N/A<STRONG>Syntax:</STRONG> BindAddress <EM>[ * | IP-address | hostname ]</EM><BR>
299N/A<STRONG>Default:</STRONG> <CODE>BindAddress *</CODE><BR>
299N/A<STRONG>Context:</STRONG> server config<BR>
299N/A<STRONG>Status:</STRONG> Core<P>
299N/A
299N/AMakes the server listen to just the specified address. If the argument
299N/Ais *, the server listens to all addresses. The port listened to
299N/Ais set with the <TT>Port</TT> directive. Only one BindAddress
299N/Ashould be used.
299N/A
299N/A<h3><A name="listen">Listen</A></h3>
299N/A<STRONG>Syntax:</STRONG> Listen <EM>[ port | IP-address:port ]</EM><BR>
299N/A<STRONG>Default:</STRONG> <CODE>none</CODE><BR>
299N/A<STRONG>Context:</STRONG> server config<BR>
299N/A<STRONG>Status:</STRONG> Core<P>
299N/A
299N/A<TT>Listen</TT> can be used instead of <TT>BindAddress</TT> and
2334N/A<TT>Port</TT>. It tells the server to accept incoming requests on the
299N/Aspecified port or address-and-port combination. If the first format is
299N/Aused, with a port number only, the server listens to the given port on
299N/Aall interfaces, instead of the port given by the <TT>Port</TT>
299N/Adirective. If an IP address is given as well as a port, the server
299N/Awill listen on the given port and interface. <P> Multiple Listen
299N/Adirectives may be used to specify a number of addresses and ports to
299N/Alisten to. The server will respond to requests from any of the listed
299N/Aaddresses and ports.<P>
299N/A
299N/AFor example, to make the server accept connections on both port
299N/A80 and port 8000, use:
299N/A<PRE>
299N/A Listen 80
299N/A Listen 8000
299N/A</PRE>
4134N/A
299N/ATo make the server accept connections on two specified
2334N/Ainterfaces and port numbers, use
299N/A<PRE>
299N/A Listen 192.170.2.1:80
299N/A Listen 192.170.2.5:8000
1242N/A</PRE>
2334N/A
1242N/A<h2>How this works with Virtual Hosts</h2>
2334N/A
1242N/ABindAddress and Listen do not implement Virtual Hosts. They tell the
1242N/Amain server what addresses and ports to listen to. If no
1242N/A&lt;VirtualHost&gt; directives are used, the server will behave the
1242N/Asame for all accepted requests. However, &lt;VirtualHost&gt; can be
2334N/Aused to specify a different behavior for one or more of the addresses
299N/Aand ports. To implement a VirtualHost, the server must first be told
299N/Ato listen to the address and port to be used. Then a
2334N/A&lt;VirtualHost&gt; section should be created for a specified address
299N/Aand port to set the behavior of this virtual host. Note that if the
299N/A&lt;VirtualHost&gt; is set for an address and port that the server is
299N/Anot listening to, it cannot be accessed.
2334N/A
299N/A<h2>See also</h2>
299N/A
299N/ASee also the documentation on
299N/A<A HREF="vhosts/index.html">Virtual Hosts</A>,
299N/A<A HREF="mod/core.html#bindaddress">BindAddress directive</A>,
299N/A<A HREF="mod/core.html#port">Port directive</A>,
299N/A<A HREF="dns-caveats.html">DNS Issues</A>
2334N/Aand
299N/A<A HREF="mod/core.html#virtualhost">&lt;VirtualHost&gt; section</A>.
299N/A
299N/A<!--#include virtual="footer.html" -->
299N/A</BODY>
299N/A</HTML>
299N/A
299N/A