mod_access.html revision 72d8c9a30f25171e5c85eeae21e0b87331bac2d9
<html>
<head>
<!--
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
This file is generated from xml source: DO NOT EDIT
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-->
<title>mod_access - Apache HTTP Server</title>
</head>
<body>
<blockquote>
<div align="center">
</div>
<h1 align="center">Apache Module mod_access</h1>
<table cellspacing="1" cellpadding="0" bgcolor="#cccccc">
<tr>
<td>
<table bgcolor="#ffffff">
<tr>
<td><span class="help">Description:</span></td><td>
<description>Provides access control based on client hostname, IP
address, or other characteristics of the client request.</description>
</td>
</tr>
<tr>
</tr>
<tr>
<td><a href="module-dict.html#ModuleIdentifier" class="help">Module Identifier:</a></td><td>access_module</td>
</tr>
</table>
</td>
</tr>
</table>
<h2>Summary</h2>
<summary>
<p>The directives provided by mod_access are used in <code class="directive"><a href="core.html#<directory>" class="directive"><Directory></a></code>, <code class="directive"><a href="core.html#<files>" class="directive"><Files></a></code>, and <code class="directive"><a href="core.html#<location>" class="directive"><Location></a></code> sections as well as
files to control access to particular parts of the server. Access
can be controlled based on the client hostname, IP address, or
other characteristics of the client request, as captured in <a href="/env.html">environment variables</a>. The <code class="directive"><a href="#allow" class="directive">Allow</a></code> and <code class="directive"><a href="#deny" class="directive">Deny</a></code> directives are used to
specify which clients are or are not allowed access to the server,
while the <code class="directive"><a href="#order" class="directive">Order</a></code>
directive sets the default access state, and configures how the
<code class="directive"><a href="#allow" class="directive">Allow</a></code> and <code class="directive"><a href="#deny" class="directive">Deny</a></code> directives interact with each
other.</p>
<p>Both host-based access restrictions and password-based
authentication may be implemented simultaneously. In that case,
the <code class="directive"><a href="core.html#satisfy" class="directive">Satisfy</a></code> directive is used
to determine how the two sets of restrictions interact.</p>
<p>In general, access restriction directives apply to all
access methods (<code>GET</code>, <code>PUT</code>,
<code>POST</code>, etc). This is the desired behavior in most
cases. However, it is possible to restrict some methods, while
leaving other methods unrestricted, by enclosing the directives
in a <code class="directive"><a href="core.html#<limit>" class="directive"><Limit></a></code> section.</p>
</summary>
<p>
<strong>See also:</strong>
</p>
<ul>
<li>
</li>
<li>
</li>
</ul>
<h2>Directives</h2>
<ul>
<li>
<a href="#allow">Allow</a>
</li>
<li>
<a href="#deny">Deny</a>
</li>
<li>
<a href="#order">Order</a>
</li>
</ul>
<hr>
<h2>
<a name="Allow">Allow</a> <a name="allow">Directive</a>
</h2>
<table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc">
<tr>
<td>
<table width="100%" bgcolor="#ffffff">
<tr>
<td><strong>Description: </strong></td><td>Controls which hosts can access an area of the
server</td>
</tr>
<tr>
<syntax> Allow from
all|<em>host</em>|env=<em>env-variable</em>
[<em>host</em>|env=<em>env-variable</em>] ...</syntax>
</td>
</tr>
<tr>
<td><a href="directive-dict.html#Context" class="help">Context:</a></td><td>directory, .htaccess</td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
</tr>
</table>
</td>
</tr>
</table>
<usage>
<p>The <code class="directive">Allow</code> directive affects which hosts can
access an area of the server. Access can be controlled by
hostname, IP Address, IP Address range, or by other
characteristics of the client request captured in environment
variables.</p>
<p>The first argument to this directive is always
<code>from</code>. The subsequent arguments can take three
different forms. If <code>Allow from all</code> is specified, then
all hosts are allowed access, subject to the configuration of the
<code class="directive"><a href="#deny" class="directive">Deny</a></code> and <code class="directive"><a href="#order" class="directive">Order</a></code> directives as discussed
below. To allow only particular hosts or groups of hosts to access
the server, the <em>host</em> can be specified in any of the
following formats:</p>
<dl>
<dt>A (partial) domain-name</dt>
<br>
Hosts whose names match, or end in, this string are allowed
access. Only complete components are matched, so the above
cause the server to perform a reverse DNS lookup on the
client IP address, regardless of the setting of the <code class="directive"><a href="core.html#hostnamelookups" class="directive">HostnameLookups</a></code>
directive.</dd>
<dt>A full IP address</dt>
<dd>Example: <code>Allow from 10.1.2.3</code>
<br>
An IP address of a host allowed access</dd>
<dt>A partial IP address</dt>
<dd>Example: <code>Allow from 10.1</code>
<br>
The first 1 to 3 bytes of an IP address, for subnet
restriction.</dd>
<dd>Example: <code>Allow from
<br>
fine-grained subnet restriction.</dd>
<br>
Similar to the previous case, except the netmask consists of
nnn high-order 1 bits.</dd>
</dl>
<p>Note that the last three examples above match exactly the
same set of hosts.</p>
<p>IPv6 addresses and IPv6 subnets can be specified as shown
below:</p>
<blockquote>
<table cellpadding="10">
<tr>
<td bgcolor="#eeeeee"><code>
Allow from fe80::a00:20ff:fea7:ccea<br>
</code></td>
</tr>
</table>
</blockquote>
<p>The third format of the arguments to the
<code class="directive">Allow</code> directive allows access to the server
to be controlled based on the existence of an <a href="/env.html">environment variable</a>. When <code>Allow from
env=</code><em>env-variable</em> is specified, then the request is
allowed access if the environment variable <em>env-variable</em>
exists. The server provides the ability to set environment
variables in a flexible way based on characteristics of the client
request using the directives provided by
used to allow access based on such factors as the clients
<code>User-Agent</code> (browser type), <code>Referer</code>, or
other HTTP request header fields.</p>
<blockquote>
<table cellpadding="10">
<tr>
<td bgcolor="#eeeeee">
<p align="center">
<strong>Example:</strong>
</p>
<code>
<Directory /docroot><br>
Order Deny,Allow<br>
Deny from all<br>
Allow from env=let_me_in<br>
</Directory>
</code></td>
</tr>
</table>
</blockquote>
<p>In this case, browsers with a user-agent string beginning
others will be denied.</p>
</usage>
<hr>
<h2>
<a name="Deny">Deny</a> <a name="deny">Directive</a>
</h2>
<table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc">
<tr>
<td>
<table width="100%" bgcolor="#ffffff">
<tr>
<td><strong>Description: </strong></td><td>Controls which hosts are denied access to the
server</td>
</tr>
<tr>
<syntax> Deny from
all|<em>host</em>|env=<em>env-variable</em>
[<em>host</em>|env=<em>env-variable</em>] ...</syntax>
</td>
</tr>
<tr>
<td><a href="directive-dict.html#Context" class="help">Context:</a></td><td>directory, .htaccess</td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
</tr>
</table>
</td>
</tr>
</table>
<usage>
<p>This directive allows access to the server to be restricted
based on hostname, IP address, or environment variables. The
arguments for the <code class="directive">Deny</code> directive are
identical to the arguments for the <code class="directive"><a href="#allow" class="directive">Allow</a></code> directive.</p>
</usage>
<hr>
<h2>
<a name="Order">Order</a> <a name="order">Directive</a>
</h2>
<table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc">
<tr>
<td>
<table width="100%" bgcolor="#ffffff">
<tr>
<td><strong>Description: </strong></td><td>Controls the default access state and the order in which
Allow and Deny are
evaluated.</td>
</tr>
<tr>
<syntax> Order <em>ordering</em>
</syntax>
</td>
</tr>
<tr>
<td><a href="directive-dict.html#Default" class="help">Default:</a></td><td><code>Order Deny,Allow</code></td>
</tr>
<tr>
<td><a href="directive-dict.html#Context" class="help">Context:</a></td><td>directory, .htaccess</td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
</tr>
</table>
</td>
</tr>
</table>
<usage>
<p>The <code class="directive">Order</code> directive controls the default
access state and the order in which <code class="directive"><a href="#allow" class="directive">Allow</a></code> and <code class="directive"><a href="#deny" class="directive">Deny</a></code> directives are evaluated.
<em>Ordering</em> is one of</p>
<dl>
<dt>Deny,Allow</dt>
<dd>The <code class="directive"><a href="#deny" class="directive">Deny</a></code> directives
are evaluated before the <code class="directive"><a href="#allow" class="directive">Allow</a></code> directives. Access is
allowed by default. Any client which does not match a
<code class="directive"><a href="#deny" class="directive">Deny</a></code> directive or does
match an <code class="directive"><a href="#allow" class="directive">Allow</a></code>
directive will be allowed access to the server.</dd>
<dt>Allow,Deny</dt>
<dd>The <code class="directive"><a href="#allow" class="directive">Allow</a></code>
directives are evaluated before the <code class="directive"><a href="#deny" class="directive">Deny</a></code> directives. Access is denied
by default. Any client which does not match an <code class="directive"><a href="#allow" class="directive">Allow</a></code> directive or does match a
<code class="directive"><a href="#deny" class="directive">Deny</a></code> directive will be
denied access to the server.</dd>
<dt>Mutual-failure</dt>
<dd>Only those hosts which appear on the <code class="directive"><a href="#allow" class="directive">Allow</a></code> list and do not appear on
the <code class="directive"><a href="#deny" class="directive">Deny</a></code> list are
granted access. This ordering has the same effect as <code>Order
Allow,Deny</code> and is deprecated in favor of that
configuration.</dd>
</dl>
<p>Keywords may only be separated by a comma; no whitespace is
allowed between them. Note that in all cases every <code class="directive"><a href="#allow" class="directive">Allow</a></code> and <code class="directive"><a href="#deny" class="directive">Deny</a></code> statement is evaluated.</p>
<p>In the following example, all hosts in the apache.org domain
are allowed access; all other hosts are denied access.</p>
<blockquote>
<table cellpadding="10">
<tr>
<td bgcolor="#eeeeee"><code>
Order Deny,Allow<br>
Deny from all<br>
Allow from apache.org<br>
</code></td>
</tr>
</table>
</blockquote>
<p>In the next example, all hosts in the apache.org domain are
allowed access, except for the hosts which are in the
foo.apache.org subdomain, who are denied access. All hosts not
in the apache.org domain are denied access because the default
state is to deny access to the server.</p>
<blockquote>
<table cellpadding="10">
<tr>
<td bgcolor="#eeeeee"><code>
Order Allow,Deny<br>
Allow from apache.org<br>
Deny from foo.apache.org<br>
</code></td>
</tr>
</table>
</blockquote>
<p>On the other hand, if the <code>Order</code> in the last
example is changed to <code>Deny,Allow</code>, all hosts will
be allowed access. This happens because, regardless of the
actual ordering of the directives in the configuration file,
be allowed access because the default state will change to
<em>allow</em>.</p>
<p>The presence of an <code>Order</code> directive can affect
access to a part of the server even in the absence of accompanying
<code class="directive"><a href="#allow" class="directive">Allow</a></code> and <code class="directive"><a href="#deny" class="directive">Deny</a></code> directives because of its effect
on the default access state. For example,</p>
<blockquote>
<table cellpadding="10">
<tr>
<td bgcolor="#eeeeee"><code>
<Directory /www><br>
Order Allow,Deny<br>
</Directory>
</code></td>
</tr>
</table>
</blockquote>
<p>will deny all access to the <code>/www</code> directory
because the default access state will be set to
<em>deny</em>.</p>
<p>The <code class="directive">Order</code> directive controls the order of access
directive processing only within each phase of the server's
configuration processing. This implies, for example, that an
<code class="directive"><a href="#allow" class="directive">Allow</a></code> or <code class="directive"><a href="#deny" class="directive">Deny</a></code> directive occurring in a
<code class="directive"><a href="core.html#<location>" class="directive"><Location></a></code> section will
always be evaluated after an <code class="directive"><a href="#allow" class="directive">Allow</a></code> or <code class="directive"><a href="#deny" class="directive">Deny</a></code> directive occurring in a
<code class="directive"><a href="core.html#<directory>" class="directive"><Directory></a></code> section or
<code>.htaccess</code> file, regardless of the setting of the
<code class="directive">Order</code> directive. For details on the merging
of configuration sections, see the documentation on <a href="/sections.html">How Directory, Location and Files sections
work</a>.</p>
</usage>
<hr>
<h3 align="center">Apache HTTP Server Version 2.0</h3>
<a href="./"><img alt="Index" src="/images/index.gif"></a><a href="../"><img alt="Home" src="/images/home.gif"></a>
</blockquote>
</body>
</html>