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