bind.xml revision f50095bc3874806a9cc5e7d283dd9051ef8a0df8
b442af56a5e2104663b84fb345c070ce185d4ab3slive<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
5f5d1b4cc970b7f06ff8ef6526128e9a27303d88nd<!-- $LastChangedRevision$ -->
6fbd2e53c97ea6976d93e0ac521adabc55e0fb73nd Licensed to the Apache Software Foundation (ASF) under one or more
acc36ab93565d2880447d535da6ca6e5feac7a70nd contributor license agreements. See the NOTICE file distributed with
acc36ab93565d2880447d535da6ca6e5feac7a70nd this work for additional information regarding copyright ownership.
acc36ab93565d2880447d535da6ca6e5feac7a70nd The ASF licenses this file to You under the Apache License, Version 2.0
acc36ab93565d2880447d535da6ca6e5feac7a70nd (the "License"); you may not use this file except in compliance with
acc36ab93565d2880447d535da6ca6e5feac7a70nd the License. You may obtain a copy of the License at
acc36ab93565d2880447d535da6ca6e5feac7a70nd Unless required by applicable law or agreed to in writing, software
acc36ab93565d2880447d535da6ca6e5feac7a70nd distributed under the License is distributed on an "AS IS" BASIS,
acc36ab93565d2880447d535da6ca6e5feac7a70nd WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
acc36ab93565d2880447d535da6ca6e5feac7a70nd See the License for the specific language governing permissions and
acc36ab93565d2880447d535da6ca6e5feac7a70nd limitations under the License.
b442af56a5e2104663b84fb345c070ce185d4ab3slive <p>Configuring Apache HTTP Server to listen on specific addresses and ports.</p>
38a01d3776f9a98839742b8f024ecb4d0d2ea613jsl </summary>
b442af56a5e2104663b84fb345c070ce185d4ab3slive <seealso><a href="vhosts/">Virtual Hosts</a></seealso>
b442af56a5e2104663b84fb345c070ce185d4ab3slive <seealso><a href="dns-caveats.html">DNS Issues</a></seealso>
b442af56a5e2104663b84fb345c070ce185d4ab3slive <modulelist>
b442af56a5e2104663b84fb345c070ce185d4ab3slive </modulelist>
09ad82b467d18345648fe3fa155a5914984980dfnd <directivelist>
b442af56a5e2104663b84fb345c070ce185d4ab3slive <directive module="core" type="section">VirtualHost</directive>
b442af56a5e2104663b84fb345c070ce185d4ab3slive </directivelist>
38a01d3776f9a98839742b8f024ecb4d0d2ea613jsl </related>
b442af56a5e2104663b84fb345c070ce185d4ab3slive <p>When httpd starts, it binds to some port and address on
b442af56a5e2104663b84fb345c070ce185d4ab3slive the local machine and waits for incoming requests. By default,
b442af56a5e2104663b84fb345c070ce185d4ab3slive it listens to all addresses on the machine. However, it may need to
b442af56a5e2104663b84fb345c070ce185d4ab3slive be told to listen on specific ports, or only on selected
b442af56a5e2104663b84fb345c070ce185d4ab3slive addresses, or a combination of both. This is often combined with the
b442af56a5e2104663b84fb345c070ce185d4ab3slive <a href="vhosts/">Virtual Host</a> feature, which determines how
b442af56a5e2104663b84fb345c070ce185d4ab3slive <code>httpd</code> responds to different IP addresses, hostnames and
b442af56a5e2104663b84fb345c070ce185d4ab3slive <p>The <directive module="mpm_common">Listen</directive>
b442af56a5e2104663b84fb345c070ce185d4ab3slive directive tells the server to accept
9530629c5ba74f47ba0bad2cd4f432c9c5cd4ff4slive incoming requests only on the specified port(s) or
9530629c5ba74f47ba0bad2cd4f432c9c5cd4ff4slive address-and-port combinations. If only a port number is
b442af56a5e2104663b84fb345c070ce185d4ab3slive specified in the <directive module="mpm_common">Listen</directive>
b442af56a5e2104663b84fb345c070ce185d4ab3slive directive, the server listens to the given port on all interfaces.
efcdf6bd09d3edaacd4db8e3b6af0678a1201d52kess If an IP address is given as well as a port, the server will listen
efcdf6bd09d3edaacd4db8e3b6af0678a1201d52kess on the given port and interface. Multiple <directive
b442af56a5e2104663b84fb345c070ce185d4ab3slive module="mpm_common">Listen</directive> directives may be used to
b442af56a5e2104663b84fb345c070ce185d4ab3slive specify a number of addresses and ports to listen on. The
b442af56a5e2104663b84fb345c070ce185d4ab3slive server will respond to requests from any of the listed
b442af56a5e2104663b84fb345c070ce185d4ab3slive addresses and ports.</p>
b442af56a5e2104663b84fb345c070ce185d4ab3slive <p>For example, to make the server accept connections on both
b442af56a5e2104663b84fb345c070ce185d4ab3slive port 80 and port 8000, on all interfaces, use:</p>
b442af56a5e2104663b84fb345c070ce185d4ab3slive </highlight>
b442af56a5e2104663b84fb345c070ce185d4ab3slive <p>To make the server accept connections on port 80 for one interface,
b442af56a5e2104663b84fb345c070ce185d4ab3slive and port 8000 on another, use</p>
b442af56a5e2104663b84fb345c070ce185d4ab3sliveListen 192.0.2.1:80
b442af56a5e2104663b84fb345c070ce185d4ab3sliveListen 192.0.2.5:8000
b442af56a5e2104663b84fb345c070ce185d4ab3slive </highlight>
b442af56a5e2104663b84fb345c070ce185d4ab3slive <p>IPv6 addresses must be enclosed in square brackets, as in the
b442af56a5e2104663b84fb345c070ce185d4ab3slive following example:</p>
b442af56a5e2104663b84fb345c070ce185d4ab3slive Listen [2001:db8::a00:20ff:fea7:ccea]:80
b442af56a5e2104663b84fb345c070ce185d4ab3slive </highlight>
b442af56a5e2104663b84fb345c070ce185d4ab3slive module="mpm_common">Listen</directive> directives will result in a
b442af56a5e2104663b84fb345c070ce185d4ab3slive fatal error which will prevent the server from starting up.</p>
4566c682d671cfda9cfcb77ea3f8e3fb8a265010trawick (48)Address already in use: make_sock: could not bind to address [::]:80
4566c682d671cfda9cfcb77ea3f8e3fb8a265010trawick href="http://wiki.apache.org/httpd/CouldNotBindToAddress">the
4566c682d671cfda9cfcb77ea3f8e3fb8a265010trawick discussion in the wiki</a> for further troubleshooting tips.</p>
ef26e16090b1b00e96bb5eb1bee6f9cee4651466jwoolley <p>A growing number of platforms implement IPv6, and
efcdf6bd09d3edaacd4db8e3b6af0678a1201d52kess <glossary>APR</glossary> supports IPv6 on most of these platforms,
efcdf6bd09d3edaacd4db8e3b6af0678a1201d52kess allowing httpd to allocate IPv6 sockets, and to handle requests sent
ef26e16090b1b00e96bb5eb1bee6f9cee4651466jwoolley over IPv6.</p>
4566c682d671cfda9cfcb77ea3f8e3fb8a265010trawick <p>One complicating factor for httpd administrators is whether or
4566c682d671cfda9cfcb77ea3f8e3fb8a265010trawick not an IPv6 socket can handle both IPv4 connections and IPv6
b442af56a5e2104663b84fb345c070ce185d4ab3slive connections. Handling IPv4 connections with an IPv6 socket uses
4566c682d671cfda9cfcb77ea3f8e3fb8a265010trawick IPv4-mapped IPv6 addresses, which are allowed by default on most
4566c682d671cfda9cfcb77ea3f8e3fb8a265010trawick platforms, but are disallowed by default on FreeBSD, NetBSD, and
efcdf6bd09d3edaacd4db8e3b6af0678a1201d52kess OpenBSD, in order to match the system-wide policy on those
efcdf6bd09d3edaacd4db8e3b6af0678a1201d52kess platforms. On systems where it is disallowed by default, a
b442af56a5e2104663b84fb345c070ce185d4ab3slive special <program>configure</program> parameter can change this behavior
b442af56a5e2104663b84fb345c070ce185d4ab3slive for httpd.</p>
4566c682d671cfda9cfcb77ea3f8e3fb8a265010trawick <p>On the other hand, on some platforms, such as Linux and Tru64, the
b442af56a5e2104663b84fb345c070ce185d4ab3slive <strong>only</strong> way to handle both IPv6 and IPv4 is to use
b442af56a5e2104663b84fb345c070ce185d4ab3slive mapped addresses. If you want <code>httpd</code> to handle IPv4 and IPv6 connections
ef26e16090b1b00e96bb5eb1bee6f9cee4651466jwoolley with a minimum of sockets, which requires using IPv4-mapped IPv6
ef26e16090b1b00e96bb5eb1bee6f9cee4651466jwoolley addresses, specify the <code>--enable-v4-mapped</code> <program>
efcdf6bd09d3edaacd4db8e3b6af0678a1201d52kess <p><code>--enable-v4-mapped</code> is the default on all platforms except
ef26e16090b1b00e96bb5eb1bee6f9cee4651466jwoolley FreeBSD, NetBSD, and OpenBSD, so this is probably how your httpd was
b442af56a5e2104663b84fb345c070ce185d4ab3slive <p>If you want httpd to handle IPv4 connections only, regardless of
b442af56a5e2104663b84fb345c070ce185d4ab3slive what your platform and APR will support, specify an IPv4 address on all
b442af56a5e2104663b84fb345c070ce185d4ab3slive <directive module="mpm_common">Listen</directive> directives, as in the
efcdf6bd09d3edaacd4db8e3b6af0678a1201d52kess following examples:</p>
b442af56a5e2104663b84fb345c070ce185d4ab3sliveListen 0.0.0.0:80
9530629c5ba74f47ba0bad2cd4f432c9c5cd4ff4sliveListen 192.0.2.1:80
9530629c5ba74f47ba0bad2cd4f432c9c5cd4ff4slive </highlight>
9530629c5ba74f47ba0bad2cd4f432c9c5cd4ff4slive <p>If your platform supports it and you want httpd to handle IPv4 and
9530629c5ba74f47ba0bad2cd4f432c9c5cd4ff4slive IPv6 connections on separate sockets (i.e., to disable IPv4-mapped
b442af56a5e2104663b84fb345c070ce185d4ab3slive addresses), specify the <code>--disable-v4-mapped</code> <program>
b442af56a5e2104663b84fb345c070ce185d4ab3slive configure</program> option. <code>--disable-v4-mapped</code> is the
9530629c5ba74f47ba0bad2cd4f432c9c5cd4ff4slive default on FreeBSD, NetBSD, and OpenBSD.</p>
9530629c5ba74f47ba0bad2cd4f432c9c5cd4ff4slive <p>The optional second <var>protocol</var> argument of
b442af56a5e2104663b84fb345c070ce185d4ab3slive is not required for most
b442af56a5e2104663b84fb345c070ce185d4ab3slive configurations. If not specified, <code>https</code> is the default for
b442af56a5e2104663b84fb345c070ce185d4ab3slive port 443 and <code>http</code> the default for all other ports. The