mirror of
https://github.com/apache/httpd.git
synced 2025-10-21 12:13:46 +03:00
Submitted by: Hiroaki KAWAI <hawk@bcl.t.u-tokyo.ac.jp> git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@96238 13f79535-47bb-0310-9956-ffa450edef68
142 lines
4.5 KiB
XML
142 lines
4.5 KiB
XML
<?xml version="1.0" encoding="UTF-8" ?>
|
|
<!DOCTYPE manualpage SYSTEM "./style/manualpage.dtd">
|
|
<?xml-stylesheet type="text/xsl" href="./style/manual.en.xsl"?>
|
|
|
|
<manualpage>
|
|
<relativepath href="."/>
|
|
|
|
<title>Binding</title>
|
|
|
|
<summary>
|
|
<p>Configuring Apache to listen on specific addresses and ports.</p>
|
|
</summary>
|
|
|
|
<seealso><a href="vhosts/">Virtual Hosts</a></seealso>
|
|
<seealso><a href="dns-caveats.html">DNS Issues</a></seealso>
|
|
|
|
<section id="overview">
|
|
<title>Overview</title>
|
|
|
|
<related>
|
|
<modulelist>
|
|
<module>core</module>
|
|
<module>mpm_common</module>
|
|
</modulelist>
|
|
<directivelist>
|
|
<directive module="core">VirtualHost</directive>
|
|
<directive module="mpm_common">Listen</directive>
|
|
</directivelist>
|
|
</related>
|
|
|
|
|
|
<p>When Apache starts, it binds to some port and address on
|
|
the local machine and waits for incoming requests. By default,
|
|
it listens to all addresses on the machine. However, it needs to
|
|
be told to listen on specific ports, or to listen on only selected
|
|
addresses, or a combination. This is often combined with the
|
|
Virtual Host feature which determines how Apache responds to
|
|
different IP addresses, hostnames and ports.</p>
|
|
|
|
<p>The <directive module="mpm_common">Listen</directive>
|
|
directive tells the server to accept
|
|
incoming requests only on the specified port or
|
|
address-and-port combinations. If only a port number is
|
|
specified in the <directive module="mpm_common">Listen</directive>
|
|
directive, the server
|
|
listens to the given port on all interfaces. If an IP address
|
|
is given as well as a port, the server will listen on the given
|
|
port and interface. Multiple Listen directives may be used to
|
|
specify a number of addresses and ports to listen on. The
|
|
server will respond to requests from any of the listed
|
|
addresses and ports.</p>
|
|
|
|
<p>For example, to make the server accept connections on both
|
|
port 80 and port 8000, use:</p>
|
|
|
|
<example>
|
|
Listen 80<br />
|
|
Listen 8000
|
|
</example>
|
|
|
|
<p>To make the server accept connections on two specified
|
|
interfaces and port numbers, use</p>
|
|
|
|
<example>
|
|
Listen 192.170.2.1:80<br />
|
|
Listen 192.170.2.5:8000
|
|
</example>
|
|
|
|
<p>IPv6 addresses must be surrounded in square brackets, as in the
|
|
following example:</p>
|
|
|
|
<example>
|
|
Listen [fe80::a00:20ff:fea7:ccea]:80
|
|
</example>
|
|
</section>
|
|
|
|
<section id="ipv6">
|
|
<title>Special IPv6 Considerations</title>
|
|
|
|
<p>When APR supports IPv6, Apache will create IPv6-capable listening
|
|
sockets by default (i.e., when no IP address is specified on the
|
|
Listen directive). In other words, when APR supports IPv6,</p>
|
|
|
|
<example>
|
|
Listen 80
|
|
</example>
|
|
|
|
<p>is equivalent to</p>
|
|
|
|
<example>
|
|
Listen [::]:80
|
|
</example>
|
|
|
|
<p>When APR does not support IPv6,</p>
|
|
|
|
<example>
|
|
Listen 80
|
|
</example>
|
|
|
|
<p>is equivalent to</p>
|
|
|
|
<example>
|
|
Listen 0.0.0.0:80
|
|
</example>
|
|
|
|
<p>On some platforms, such as NetBSD, binding to the IPv6 wildcard address
|
|
("::") does not allow Apache to accept connections on IPv4 interfaces.
|
|
In this situation, multiple Listen directives are required, as shown
|
|
below:</p>
|
|
|
|
<example>
|
|
Listen 0.0.0.0:80<br />
|
|
Listen [::]:0
|
|
</example>
|
|
|
|
<p>Apache does not currently detect this, so the Listen statements must
|
|
be edited manually by the administrator.</p>
|
|
</section>
|
|
|
|
<section id="virtualhost">
|
|
<title>How This Works With Virtual Hosts</title>
|
|
|
|
<p>Listen does not implement Virtual Hosts. It only tells the
|
|
main server what addresses and ports to listen to. If no
|
|
<directive module="core" type="section">VirtualHost</directive>
|
|
directives are used, the server will behave
|
|
the same for all accepted requests. However,
|
|
<directive module="core" type="section">VirtualHost</directive>
|
|
can be used to specify a different behavior
|
|
for one or more of the addresses and ports. To implement a
|
|
VirtualHost, the server must first be told to listen to the
|
|
address and port to be used. Then a
|
|
<directive module="core" type="section">VirtualHost</directive> section
|
|
should be created for a specified address and port to set the
|
|
behavior of this virtual host. Note that if the
|
|
<directive module="core" type="section">VirtualHost</directive>
|
|
is set for an address and port that the
|
|
server is not listening to, it cannot be accessed.</p>
|
|
</section>
|
|
</manualpage>
|
|
|