bind.html revision 3915c6d87a89ccc69242e7a7a535e713b0575399
2d453384452f29ab46f29c0163a830492f936512Till Mossakowski<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2d453384452f29ab46f29c0163a830492f936512Till Mossakowski<TITLE>Setting which addresses and ports Apache uses</TITLE>
2d453384452f29ab46f29c0163a830492f936512Till Mossakowski<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
2d453384452f29ab46f29c0163a830492f936512Till Mossakowski BGCOLOR="#FFFFFF"
c673000621dd506e5fc7babf8ca6303b7fcefc14Christian Maeder TEXT="#000000"
2d453384452f29ab46f29c0163a830492f936512Till Mossakowski LINK="#0000FF"
f3a94a197960e548ecd6520bb768cb0d547457bbChristian Maeder VLINK="#000080"
2d453384452f29ab46f29c0163a830492f936512Till Mossakowski ALINK="#FF0000"
1f084d62dbf8ae72357697c226cacd1973f0c03fTill Mossakowski<!--#include virtual="header.html" -->
8a8e8dfa317cdb486ca05d71996a27d60bf3c718Christian Maeder<H1 ALIGN="CENTER">Setting which addresses and ports Apache uses</H1>
2d453384452f29ab46f29c0163a830492f936512Till Mossakowski<p>When Apache starts, it connects to some port and address on the
613bf0ed7d98a961755408ead328687ec17f74fdChristian Maederlocal machine and waits for incoming requests. By default, it
613bf0ed7d98a961755408ead328687ec17f74fdChristian Maederlistens to all addresses on the machine, and to the port
613bf0ed7d98a961755408ead328687ec17f74fdChristian Maederas specified by the <code>Port</code> directive in the server configuration.
613bf0ed7d98a961755408ead328687ec17f74fdChristian MaederHowever, it can be told to listen to more the one port, or to listen
613bf0ed7d98a961755408ead328687ec17f74fdChristian Maederto only selected addresses, or a combination. This is often combined
613bf0ed7d98a961755408ead328687ec17f74fdChristian Maederwith the Virtual Host feature which determines how Apache
613bf0ed7d98a961755408ead328687ec17f74fdChristian Maederresponds to different IP addresses, hostnames and ports.</p>
4eed11f3c47a94e8908e15a0af70370ad35b3586Paolo Torrini<p>The <code>Listen</code> directive tells the server to accept
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maederincoming requests only on the specified port or address-and-port
1c8c2ec97ff7dee8381aca53f0fca99c01f7b32fSonja Gröningcombinations. If only a port number is specified in the
68c2f69423ac541f27a8096b05e882791064af9dPaolo Torrini<code>Listen</code> directive, the server listens to the given port on
f9d28459072c85d4ae0bc12c1d7e4f0b57f33ae1Christian Maederall interfaces, instead of the port given by the <code>Port</code>
1c8c2ec97ff7dee8381aca53f0fca99c01f7b32fSonja Gröningdirective. If an IP address is given as well as a port, the server
0f2a8687ec78c69557d72accbc33fd759f922b46Sonja Gröningwill listen on the given port and interface. Multiple Listen
62dd3cd58cda003c32ac69ff12dc82b0a6f5d9d3Christian Maederdirectives may be used to specify a number of addresses and ports to
62dd3cd58cda003c32ac69ff12dc82b0a6f5d9d3Christian Maederlisten to. The server will respond to requests from any of the listed
1c8c2ec97ff7dee8381aca53f0fca99c01f7b32fSonja Gröningaddresses and ports.</P>
7f6b97541fdee30d62a0a3cfa58173212a6cd002Christian Maeder<p>For example, to make the server accept connections on both port
7f6b97541fdee30d62a0a3cfa58173212a6cd002Christian Maeder80 and port 8000, use:
d6025ee06343191f356a59704d467866afa29900Paolo TorriniTo make the server accept connections on two specified
1c8c2ec97ff7dee8381aca53f0fca99c01f7b32fSonja Gröninginterfaces and port numbers, use
4c8d161489d17edf1e15f16a1fbb5638c8c61856Sonja Gröning Listen 192.170.2.1:80
1c8c2ec97ff7dee8381aca53f0fca99c01f7b32fSonja Gröning Listen 192.170.2.5:8000
8a8e8dfa317cdb486ca05d71996a27d60bf3c718Christian Maeder<p>Listen does not implement Virtual Hosts. It only tells the
62dd3cd58cda003c32ac69ff12dc82b0a6f5d9d3Christian Maedermain server what addresses and ports to listen to. If no
4eed11f3c47a94e8908e15a0af70370ad35b3586Paolo Torrini<VirtualHost> directives are used, the server will behave the
62dd3cd58cda003c32ac69ff12dc82b0a6f5d9d3Christian Maedersame for all accepted requests. However, <VirtualHost> can be
62dd3cd58cda003c32ac69ff12dc82b0a6f5d9d3Christian Maederused to specify a different behavior for one or more of the addresses
4eed11f3c47a94e8908e15a0af70370ad35b3586Paolo Torriniand ports. To implement a VirtualHost, the server must first be told
62dd3cd58cda003c32ac69ff12dc82b0a6f5d9d3Christian Maederto listen to the address and port to be used. Then a
62dd3cd58cda003c32ac69ff12dc82b0a6f5d9d3Christian Maeder<VirtualHost> section should be created for a specified address
62dd3cd58cda003c32ac69ff12dc82b0a6f5d9d3Christian Maederand port to set the behavior of this virtual host. Note that if the
62dd3cd58cda003c32ac69ff12dc82b0a6f5d9d3Christian Maeder<VirtualHost> is set for an address and port that the server is
4eed11f3c47a94e8908e15a0af70370ad35b3586Paolo Torrininot listening to, it cannot be accessed.
bb027d3cacbd83dfec98beb38001f105e4918557Christian MaederSee also the documentation on
bb027d3cacbd83dfec98beb38001f105e4918557Christian Maeder<a href="mod/mpm_common.html#listen">Listen directive</a>,
613bf0ed7d98a961755408ead328687ec17f74fdChristian Maeder<A HREF="vhosts/index.html">Virtual Hosts</A>,
613bf0ed7d98a961755408ead328687ec17f74fdChristian Maeder<A HREF="mod/core.html#port">Port directive</A>,
613bf0ed7d98a961755408ead328687ec17f74fdChristian Maeder<A HREF="mod/core.html#virtualhost"><VirtualHost> section</A>.
613bf0ed7d98a961755408ead328687ec17f74fdChristian Maeder<!--#include virtual="footer.html" -->