mod_access_compat.xml revision 6f10385908fbdfd4849e4bc50e690ee54c62f2cd
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd<!DOCTYPE modulesynopsis SYSTEM "/style/modulesynopsis.dtd">
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd<!-- $LastChangedRevision$ -->
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd Licensed to the Apache Software Foundation (ASF) under one or more
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd contributor license agreements. See the NOTICE file distributed with
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd this work for additional information regarding copyright ownership.
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd The ASF licenses this file to You under the Apache License, Version 2.0
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd (the "License"); you may not use this file except in compliance with
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd the License. You may obtain a copy of the License at
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd Unless required by applicable law or agreed to in writing, software
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd distributed under the License is distributed on an "AS IS" BASIS,
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
c82fca6d3f5608b946f18d37e8710b1d71e3478dnd See the License for the specific language governing permissions and
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd limitations under the License.
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd<description>Group authorizations based on host (name or IP
d3a9ab99d53a956d1c5ee9ef343188b508a80058ndaddress)</description>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd<compatibility>Available in Apache HTTP Server 2.3 as a compatibility module with
d3a9ab99d53a956d1c5ee9ef343188b508a80058ndprevious versions of Apache httpd 2.x. The directives provided by this module
d3a9ab99d53a956d1c5ee9ef343188b508a80058ndhave been deprecated by the new authz refactoring. Please see
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <p>The directives provided by <module>mod_access_compat</module> are
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd used in <directive module="core" type="section">Directory</directive>,
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <directive module="core" type="section">Files</directive>, and
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <directive module="core" type="section">Location</directive> sections
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd as well as <code><a href="core.html#accessfilename">.htaccess</a>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd </code> files to control access to particular parts of the server.
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd Access can be controlled based on the client hostname, IP address, or
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd other characteristics of the client request, as captured in <a
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd href="/env.html">environment variables</a>. The <directive
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd module="mod_access_compat">Allow</directive> and <directive
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd module="mod_access_compat">Deny</directive> directives are used to
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd specify which clients are or are not allowed access to the server,
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd while the <directive module="mod_access_compat">Order</directive>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd directive sets the default access state, and configures how the
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <directive module="mod_access_compat">Allow</directive> and <directive
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd module="mod_access_compat">Deny</directive> directives interact with each
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd other.</p>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <p>Both host-based access restrictions and password-based
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd authentication may be implemented simultaneously. In that case,
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd the <directive module="mod_access_compat">Satisfy</directive> directive is used
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd to determine how the two sets of restrictions interact.</p>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <p>The directives provided by <module>mod_access_compat</module> have
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd been deprecated by the new authz refactoring. Please see
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <p>In general, access restriction directives apply to all
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <code>POST</code>, etc). This is the desired behavior in most
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd cases. However, it is possible to restrict some methods, while
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd leaving other methods unrestricted, by enclosing the directives
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd in a <directive module="core" type="section">Limit</directive> section.</p>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <p>When any directive provided by this module is used in a new
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd configuration section, no directives provided by this module are
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd inherited from previous configuration sections.</p>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd<seealso><directive module="mod_authz_core">Require</directive></seealso>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd<directivesynopsis>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd<description>Controls which hosts can access an area of the
d3a9ab99d53a956d1c5ee9ef343188b508a80058ndserver</description>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd<syntax> Allow from all|<var>host</var>|env=[!]<var>env-variable</var>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd[<var>host</var>|env=[!]<var>env-variable</var>] ...</syntax>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd<contextlist><context>directory</context><context>.htaccess</context>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd</contextlist>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <p>The <directive>Allow</directive> directive affects which hosts can
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd access an area of the server. Access can be controlled by
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd hostname, IP address, IP address range, or by other
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd characteristics of the client request captured in environment
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd variables.</p>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <p>The first argument to this directive is always
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <code>from</code>. The subsequent arguments can take three
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd different forms. If <code>Allow from all</code> is specified, then
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd all hosts are allowed access, subject to the configuration of the
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <directive module="mod_access_compat">Deny</directive> and <directive
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd module="mod_access_compat">Order</directive> directives as discussed
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd below. To allow only particular hosts or groups of hosts to access
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd the server, the <em>host</em> can be specified in any of the
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd following formats:</p>
d3a9ab99d53a956d1c5ee9ef343188b508a80058ndAllow from .net example.edu
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd </highlight>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <p>Hosts whose names match, or end in, this string are allowed
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd access. Only complete components are matched, so the above
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd example will match <code>foo.example.org</code> but it will not
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd match <code>fooexample.org</code>. This configuration will cause
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd Apache httpd to perform a double DNS lookup on the client IP
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd address, regardless of the setting of the <directive
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd module="core">HostnameLookups</directive> directive. It will do
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd a reverse DNS lookup on the IP address to find the associated
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd hostname, and then do a forward lookup on the hostname to assure
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd that it matches the original IP address. Only if the forward
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd and reverse DNS are consistent and the hostname matches will
d3a9ab99d53a956d1c5ee9ef343188b508a80058ndAllow from 10.1.2.3
d3a9ab99d53a956d1c5ee9ef343188b508a80058ndAllow from 192.168.1.104 192.168.1.205
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd </highlight>
d3a9ab99d53a956d1c5ee9ef343188b508a80058ndAllow from 10.1
d3a9ab99d53a956d1c5ee9ef343188b508a80058ndAllow from 10 172.20 192.168.2
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd </highlight>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <p>The first 1 to 3 bytes of an IP address, for subnet
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd </highlight>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd </highlight>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <p>Similar to the previous case, except the netmask consists of
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <p>Note that the last three examples above match exactly the
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd same set of hosts.</p>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <p>IPv6 addresses and IPv6 subnets can be specified as shown
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd below:</p>
d3a9ab99d53a956d1c5ee9ef343188b508a80058ndAllow from 2001:db8::a00:20ff:fea7:ccea
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd </highlight>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <p>The third format of the arguments to the
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <directive>Allow</directive> directive allows access to the server
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd to be controlled based on the existence of an <a
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd href="/env.html">environment variable</a>. When <code>Allow from
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd env=<var>env-variable</var></code> is specified, then the request is
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd allowed access if the environment variable <var>env-variable</var>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd exists. When <code>Allow from env=!<var>env-variable</var></code> is
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd specified, then the request is allowed access if the environment
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd The server provides the ability to set environment
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd variables in a flexible way based on characteristics of the client
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd request using the directives provided by
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <module>mod_setenvif</module>. Therefore, this directive can be
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd used to allow access based on such factors as the clients
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <code>User-Agent</code> (browser type), <code>Referer</code>, or
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd other HTTP request header fields.</p>
d3a9ab99d53a956d1c5ee9ef343188b508a80058ndSetEnvIf User-Agent ^KnockKnock/2\.0 let_me_in
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd<Directory /docroot>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd Order Deny,Allow
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd Deny from all
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd Allow from env=let_me_in
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd</Directory>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd </highlight>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <p>In this case, browsers with a user-agent string beginning
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd with <code>KnockKnock/2.0</code> will be allowed access, and all
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd others will be denied.</p>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <p>When any directive provided by this module is used in a new
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd configuration section, no directives provided by this module are
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd inherited from previous configuration sections.</p>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd</directivesynopsis>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd<directivesynopsis>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd<description>Controls which hosts are denied access to the
d3a9ab99d53a956d1c5ee9ef343188b508a80058ndserver</description>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd<syntax> Deny from all|<var>host</var>|env=[!]<var>env-variable</var>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd[<var>host</var>|env=[!]<var>env-variable</var>] ...</syntax>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd<contextlist><context>directory</context><context>.htaccess</context>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd</contextlist>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <p>This directive allows access to the server to be restricted
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd based on hostname, IP address, or environment variables. The
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd arguments for the <directive>Deny</directive> directive are
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd identical to the arguments for the <directive
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd module="mod_access_compat">Allow</directive> directive.</p>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd</directivesynopsis>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd<directivesynopsis>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd<description>Controls the default access state and the order in which
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd<directive>Allow</directive> and <directive>Deny</directive> are
d3a9ab99d53a956d1c5ee9ef343188b508a80058ndevaluated.</description>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd<contextlist><context>directory</context><context>.htaccess</context>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd</contextlist>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <p>The <directive>Order</directive> directive, along with the
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <directive module="mod_access_compat">Allow</directive> and
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <directive module="mod_access_compat">Deny</directive> directives,
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd controls a three-pass access control system. The first pass
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd processes either all <directive
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd module="mod_access_compat">Allow</directive> or all <directive
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd module="mod_access_compat">Deny</directive> directives, as specified
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd by the <directive module="mod_access_compat">Order</directive>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd directive. The second pass parses the rest of the directives
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd (<directive module="mod_access_compat">Deny</directive> or
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd <directive module="mod_access_compat">Allow</directive>). The third
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd pass applies to all requests which do not match either of the first
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd module="mod_access_compat">Allow</directive> and <directive
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd module="mod_access_compat">Deny</directive> directives are
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd processed, unlike a typical firewall, where only the first match is
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd used. The last match is effective (also unlike a typical firewall).
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd Additionally, the order in which lines appear in the configuration
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd files is not significant -- all <directive
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd module="mod_access_compat">Allow</directive> lines are processed as
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd one group, all <directive
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd module="mod_access_compat">Deny</directive> lines are considered as
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd another, and the default state is considered by itself.</p>
d3a9ab99d53a956d1c5ee9ef343188b508a80058nd module="mod_access_compat">Allow</directive> directives are
Allow from example.org
foo.example.org subdomain, who are denied access. All hosts not
in the example.org domain are denied access because the default
Allow from example.org
Deny from foo.example.org
href="/sections.html">How Directory, Location and Files sections