1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
4 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5 This file is generated from xml source: DO NOT EDIT
6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
8 <title>mod_access_compat - Apache HTTP Server</title>
9 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
10 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
11 <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
12 <link href="../images/favicon.ico" rel="shortcut icon" /></head>
14 <div id="page-header">
15 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
16 <p class="apache">Apache HTTP Server Version 2.3</p>
17 <img alt="" src="../images/feather.gif" /></div>
18 <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div>
20 <a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.3</a> > <a href="./">Modules</a></div>
21 <div id="page-content">
22 <div id="preamble"><h1>Apache Module mod_access_compat</h1>
24 <p><span>Available Languages: </span><a href="../en/mod/mod_access_compat.html" title="English"> en </a> |
25 <a href="../fr/mod/mod_access_compat.html" hreflang="fr" rel="alternate" title="Français"> fr </a> |
26 <a href="../ja/mod/mod_access_compat.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a></p>
28 <table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Group authorizations based on host (name or IP
30 <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Extension</td></tr>
31 <tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>access_compat_module</td></tr>
32 <tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>mod_access_compat.c</td></tr>
33 <tr><th><a href="module-dict.html#Compatibility">Compatibility:</a></th><td>Available in Apache 2.3 as a compatibility module with
34 previous versions of Apache 2.x. The directives provided by this module
35 have been deprecated by the new authz refactoring. Please see
36 <code class="module"><a href="../mod/mod_authz_host.html">mod_authz_host</a></code></td></tr></table>
39 <p>The directives provided by <code class="module"><a href="../mod/mod_access_compat.html">mod_access_compat</a></code> are
40 used in <code class="directive"><a href="../mod/core.html#directory"><Directory></a></code>,
41 <code class="directive"><a href="../mod/core.html#files"><Files></a></code>, and
42 <code class="directive"><a href="../mod/core.html#location"><Location></a></code> sections
43 as well as <code><a href="core.html#accessfilename">.htaccess</a>
44 </code> files to control access to particular parts of the server.
45 Access can be controlled based on the client hostname, IP address, or
46 other characteristics of the client request, as captured in <a href="../env.html">environment variables</a>. The <code class="directive"><a href="#allow">Allow</a></code> and <code class="directive"><a href="#deny">Deny</a></code> directives are used to
47 specify which clients are or are not allowed access to the server,
48 while the <code class="directive"><a href="#order">Order</a></code>
49 directive sets the default access state, and configures how the
50 <code class="directive"><a href="#allow">Allow</a></code> and <code class="directive"><a href="#deny">Deny</a></code> directives interact with each
53 <p>Both host-based access restrictions and password-based
54 authentication may be implemented simultaneously. In that case,
55 the <code class="directive"><a href="#satisfy">Satisfy</a></code> directive is used
56 to determine how the two sets of restrictions interact.</p>
58 <div class="warning"><h3>Note</h3>
59 <p>The directives provided by <code class="module"><a href="../mod/mod_access_compat.html">mod_access_compat</a></code> have
60 been deprecated by the new authz refactoring. Please see
61 <code class="module"><a href="../mod/mod_authz_host.html">mod_authz_host</a></code>.</p>
64 <p>In general, access restriction directives apply to all
65 access methods (<code>GET</code>, <code>PUT</code>,
66 <code>POST</code>, etc). This is the desired behavior in most
67 cases. However, it is possible to restrict some methods, while
68 leaving other methods unrestricted, by enclosing the directives
69 in a <code class="directive"><a href="../mod/core.html#limit"><Limit></a></code> section.</p>
71 <div id="quickview"><h3 class="directives">Directives</h3>
73 <li><img alt="" src="../images/down.gif" /> <a href="#allow">Allow</a></li>
74 <li><img alt="" src="../images/down.gif" /> <a href="#deny">Deny</a></li>
75 <li><img alt="" src="../images/down.gif" /> <a href="#order">Order</a></li>
76 <li><img alt="" src="../images/down.gif" /> <a href="#satisfy">Satisfy</a></li>
80 <li><code class="directive"><a href="../mod/mod_authz_core.html#require">Require</a></code></li>
81 <li><code class="module"><a href="../mod/mod_authz_host.html">mod_authz_host</a></code></li>
82 <li><code class="module"><a href="../mod/mod_authz_core.html">mod_authz_core</a></code></li>
85 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
86 <div class="directive-section"><h2><a name="Allow" id="Allow">Allow</a> <a name="allow" id="allow">Directive</a></h2>
87 <table class="directive">
88 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Controls which hosts can access an area of the
90 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code> Allow from all|<var>host</var>|env=[!]<var>env-variable</var>
91 [<var>host</var>|env=[!]<var>env-variable</var>] ...</code></td></tr>
92 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory, .htaccess</td></tr>
93 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>Limit</td></tr>
94 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
95 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_access_compat</td></tr>
97 <p>The <code class="directive">Allow</code> directive affects which hosts can
98 access an area of the server. Access can be controlled by
99 hostname, IP address, IP address range, or by other
100 characteristics of the client request captured in environment
103 <p>The first argument to this directive is always
104 <code>from</code>. The subsequent arguments can take three
105 different forms. If <code>Allow from all</code> is specified, then
106 all hosts are allowed access, subject to the configuration of the
107 <code class="directive"><a href="#deny">Deny</a></code> and <code class="directive"><a href="#order">Order</a></code> directives as discussed
108 below. To allow only particular hosts or groups of hosts to access
109 the server, the <em>host</em> can be specified in any of the
110 following formats:</p>
113 <dt>A (partial) domain-name</dt>
116 <div class="example"><h3>Example:</h3><p><code>
117 Allow from apache.org<br />
118 Allow from .net example.edu
120 <p>Hosts whose names match, or end in, this string are allowed
121 access. Only complete components are matched, so the above
122 example will match <code>foo.apache.org</code> but it will not
123 match <code>fooapache.org</code>. This configuration will cause
124 Apache to perform a double DNS lookup on the client IP
125 address, regardless of the setting of the <code class="directive"><a href="../mod/core.html#hostnamelookups">HostnameLookups</a></code> directive. It will do
126 a reverse DNS lookup on the IP address to find the associated
127 hostname, and then do a forward lookup on the hostname to assure
128 that it matches the original IP address. Only if the forward
129 and reverse DNS are consistent and the hostname matches will
130 access be allowed.</p></dd>
132 <dt>A full IP address</dt>
135 <div class="example"><h3>Example:</h3><p><code>
136 Allow from 10.1.2.3<br />
137 Allow from 192.168.1.104 192.168.1.205
139 <p>An IP address of a host allowed access</p></dd>
141 <dt>A partial IP address</dt>
144 <div class="example"><h3>Example:</h3><p><code>
145 Allow from 10.1<br />
146 Allow from 10 172.20 192.168.2
148 <p>The first 1 to 3 bytes of an IP address, for subnet
149 restriction.</p></dd>
151 <dt>A network/netmask pair</dt>
154 <div class="example"><h3>Example:</h3><p><code>
155 Allow from 10.1.0.0/255.255.0.0
157 <p>A network a.b.c.d, and a netmask w.x.y.z. For more
158 fine-grained subnet restriction.</p></dd>
160 <dt>A network/nnn CIDR specification</dt>
163 <div class="example"><h3>Example:</h3><p><code>
164 Allow from 10.1.0.0/16
166 <p>Similar to the previous case, except the netmask consists of
167 nnn high-order 1 bits.</p></dd>
170 <p>Note that the last three examples above match exactly the
171 same set of hosts.</p>
173 <p>IPv6 addresses and IPv6 subnets can be specified as shown
176 <div class="example"><p><code>
177 Allow from 2001:db8::a00:20ff:fea7:ccea<br />
178 Allow from 2001:db8::a00:20ff:fea7:ccea/10
181 <p>The third format of the arguments to the
182 <code class="directive">Allow</code> directive allows access to the server
183 to be controlled based on the existence of an <a href="../env.html">environment variable</a>. When <code>Allow from
184 env=<var>env-variable</var></code> is specified, then the request is
185 allowed access if the environment variable <var>env-variable</var>
186 exists. When <code>Allow from env=!<var>env-variable</var></code> is
187 specified, then the request is allowed access if the environment
188 variable <var>env-variable</var> doesn't exist.
189 The server provides the ability to set environment
190 variables in a flexible way based on characteristics of the client
191 request using the directives provided by
192 <code class="module"><a href="../mod/mod_setenvif.html">mod_setenvif</a></code>. Therefore, this directive can be
193 used to allow access based on such factors as the clients
194 <code>User-Agent</code> (browser type), <code>Referer</code>, or
195 other HTTP request header fields.</p>
197 <div class="example"><h3>Example:</h3><p><code>
198 SetEnvIf User-Agent ^KnockKnock/2\.0 let_me_in<br />
199 <Directory /docroot><br />
200 <span class="indent">
201 Order Deny,Allow<br />
203 Allow from env=let_me_in<br />
208 <p>In this case, browsers with a user-agent string beginning
209 with <code>KnockKnock/2.0</code> will be allowed access, and all
210 others will be denied.</p>
213 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
214 <div class="directive-section"><h2><a name="Deny" id="Deny">Deny</a> <a name="deny" id="deny">Directive</a></h2>
215 <table class="directive">
216 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Controls which hosts are denied access to the
218 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code> Deny from all|<var>host</var>|env=[!]<var>env-variable</var>
219 [<var>host</var>|env=[!]<var>env-variable</var>] ...</code></td></tr>
220 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory, .htaccess</td></tr>
221 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>Limit</td></tr>
222 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
223 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_access_compat</td></tr>
225 <p>This directive allows access to the server to be restricted
226 based on hostname, IP address, or environment variables. The
227 arguments for the <code class="directive">Deny</code> directive are
228 identical to the arguments for the <code class="directive"><a href="#allow">Allow</a></code> directive.</p>
231 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
232 <div class="directive-section"><h2><a name="Order" id="Order">Order</a> <a name="order" id="order">Directive</a></h2>
233 <table class="directive">
234 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Controls the default access state and the order in which
235 <code class="directive">Allow</code> and <code class="directive">Deny</code> are
237 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code> Order <var>ordering</var></code></td></tr>
238 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>Order Deny,Allow</code></td></tr>
239 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory, .htaccess</td></tr>
240 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>Limit</td></tr>
241 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
242 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_access_compat</td></tr>
245 <p>The <code class="directive">Order</code> directive, along with the
246 <code class="directive"><a href="#allow">Allow</a></code> and
247 <code class="directive"><a href="#deny">Deny</a></code> directives,
248 controls a three-pass access control system. The first pass
249 processes either all <code class="directive"><a href="#allow">Allow</a></code> or all <code class="directive"><a href="#deny">Deny</a></code> directives, as specified
250 by the <code class="directive"><a href="#order">Order</a></code>
251 directive. The second pass parses the rest of the directives
252 (<code class="directive"><a href="#deny">Deny</a></code> or
253 <code class="directive"><a href="#allow">Allow</a></code>). The third
254 pass applies to all requests which do not match either of the first
257 <p>Note that all <code class="directive"><a href="#allow">Allow</a></code> and <code class="directive"><a href="#deny">Deny</a></code> directives are
258 processed, unlike a typical firewall, where only the first match is
259 used. The last match is effective (also unlike a typical firewall).
260 Additionally, the order in which lines appear in the configuration
261 files is not significant -- all <code class="directive"><a href="#allow">Allow</a></code> lines are processed as
262 one group, all <code class="directive"><a href="#deny">Deny</a></code> lines are considered as
263 another, and the default state is considered by itself.</p>
265 <p><em>Ordering</em> is one of:</p>
268 <dt><code>Allow,Deny</code></dt>
270 <dd>First, all <code class="directive"><a href="#allow">Allow</a></code> directives are
271 evaluated; at least one must match, or the request is rejected.
272 Next, all <code class="directive"><a href="#deny">Deny</a></code>
273 directives are evaluated. If any matches, the request is rejected.
274 Last, any requests which do not match an <code class="directive"><a href="#allow">Allow</a></code> or a <code class="directive"><a href="#deny">Deny</a></code> directive are denied
277 <dt><code>Deny,Allow</code></dt>
279 <dd>First, all <code class="directive"><a href="#deny">Deny</a></code> directives are
280 evaluated; if any match, the request is denied
281 <strong>unless</strong> it also matches an <code class="directive"><a href="#allow">Allow</a></code> directive. Any
282 requests which do not match any <code class="directive"><a href="#allow">Allow</a></code> or <code class="directive"><a href="#deny">Deny</a></code> directives are
285 <dt><code>Mutual-failure</code></dt>
287 <dd>This order has the same effect as <code>Order
288 Allow,Deny</code> and is deprecated in its favor.</dd>
291 <p>Keywords may only be separated by a comma; <em>no whitespace</em>
292 is allowed between them.</p>
294 <table class="bordered">
297 <th>Allow,Deny result</th>
298 <th>Deny,Allow result</th>
300 <th>Match Allow only</th>
301 <td>Request allowed</td>
302 <td>Request allowed</td>
304 <th>Match Deny only</th>
305 <td>Request denied</td>
306 <td>Request denied</td>
309 <td>Default to second directive: Denied</td>
310 <td>Default to second directive: Allowed</td>
312 <th>Match both Allow & Deny</th>
313 <td>Final match controls: Denied</td>
314 <td>Final match controls: Allowed</td>
318 <p>In the following example, all hosts in the apache.org domain
319 are allowed access; all other hosts are denied access.</p>
321 <div class="example"><p><code>
322 Order Deny,Allow<br />
324 Allow from apache.org
327 <p>In the next example, all hosts in the apache.org domain are
328 allowed access, except for the hosts which are in the
329 foo.apache.org subdomain, who are denied access. All hosts not
330 in the apache.org domain are denied access because the default
331 state is to <code class="directive"><a href="#deny">Deny</a></code>
332 access to the server.</p>
334 <div class="example"><p><code>
335 Order Allow,Deny<br />
336 Allow from apache.org<br />
337 Deny from foo.apache.org
340 <p>On the other hand, if the <code class="directive">Order</code> in the
341 last example is changed to <code>Deny,Allow</code>, all hosts will
342 be allowed access. This happens because, regardless of the actual
343 ordering of the directives in the configuration file, the
344 <code>Allow from apache.org</code> will be evaluated last and will
345 override the <code>Deny from foo.apache.org</code>. All hosts not in
346 the <code>apache.org</code> domain will also be allowed access
347 because the default state is <code class="directive"><a href="#allow">Allow</a></code>.</p>
349 <p>The presence of an <code class="directive">Order</code> directive can
350 affect access to a part of the server even in the absence of
351 accompanying <code class="directive"><a href="#allow">Allow</a></code>
352 and <code class="directive"><a href="#deny">Deny</a></code>
353 directives because of its effect on the default access state. For
356 <div class="example"><p><code>
357 <Directory /www><br />
358 <span class="indent">
359 Order Allow,Deny<br />
364 <p>will Deny all access to the <code>/www</code> directory
365 because the default access state is set to
366 <code class="directive"><a href="#deny">Deny</a></code>.</p>
368 <p>The <code class="directive">Order</code> directive controls the order of access
369 directive processing only within each phase of the server's
370 configuration processing. This implies, for example, that an
371 <code class="directive"><a href="#allow">Allow</a></code> or <code class="directive"><a href="#deny">Deny</a></code> directive occurring in a
372 <code class="directive"><a href="../mod/core.html#location"><Location></a></code> section will
373 always be evaluated after an <code class="directive"><a href="#allow">Allow</a></code> or <code class="directive"><a href="#deny">Deny</a></code> directive occurring in a
374 <code class="directive"><a href="../mod/core.html#directory"><Directory></a></code> section or
375 <code>.htaccess</code> file, regardless of the setting of the
376 <code class="directive">Order</code> directive. For details on the merging
377 of configuration sections, see the documentation on <a href="../sections.html">How Directory, Location and Files sections
381 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
382 <div class="directive-section"><h2><a name="Satisfy" id="Satisfy">Satisfy</a> <a name="satisfy" id="satisfy">Directive</a></h2>
383 <table class="directive">
384 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Interaction between host-level access control and
385 user authentication</td></tr>
386 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>Satisfy Any|All</code></td></tr>
387 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>Satisfy All</code></td></tr>
388 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory, .htaccess</td></tr>
389 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>AuthConfig</td></tr>
390 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
391 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_access_compat</td></tr>
392 <tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Influenced by <code class="directive"><a href="../mod/core.html#limit"><Limit></a></code> and <code class="directive"><a href="../mod/core.html#limitexcept"><LimitExcept></a></code> in version 2.0.51 and
395 <p>Access policy if both <code class="directive"><a href="#allow">Allow</a></code> and <code class="directive"><a href="../mod/mod_authz_core.html#require">Require</a></code> used. The parameter can be
396 either <code>All</code> or <code>Any</code>. This directive is only
397 useful if access to a particular area is being restricted by both
398 username/password <em>and</em> client host address. In this case
399 the default behavior (<code>All</code>) is to require that the client
400 passes the address access restriction <em>and</em> enters a valid
401 username and password. With the <code>Any</code> option the client will be
402 granted access if they either pass the host restriction or enter a
403 valid username and password. This can be used to password restrict
404 an area, but to let clients from particular addresses in without
405 prompting for a password.</p>
407 <p>For example, if you wanted to let people on your network have
408 unrestricted access to a portion of your website, but require that
409 people outside of your network provide a password, you could use a
410 configuration similar to the following:</p>
412 <div class="example"><p><code>
413 Require valid-user<br />
414 Allow from 192.168.1<br />
419 Another frequent use of the <code class="directive">Satisfy</code> directive
420 is to relax access restrictions for a subdirectory:
423 <div class="example"><p><code>
424 <Directory /var/www/private><br />
425 Require valid-user<br />
426 </Directory><br />
428 <Directory /var/www/private/public><br />
434 <p>In the above example, authentication will be required for the
435 <code>/var/www/private</code> directory, but will not be required
436 for the <code>/var/www/private/public</code> directory.</p>
438 <p>Since version 2.0.51 <code class="directive">Satisfy</code> directives can
439 be restricted to particular methods by <code class="directive"><a href="../mod/core.html#limit"><Limit></a></code> and <code class="directive"><a href="../mod/core.html#limitexcept"><LimitExcept></a></code> sections.</p>
443 <li><code class="directive"><a href="#allow">Allow</a></code></li>
444 <li><code class="directive"><a href="../mod/mod_authz_core.html#require">Require</a></code></li>
448 <div class="bottomlang">
449 <p><span>Available Languages: </span><a href="../en/mod/mod_access_compat.html" title="English"> en </a> |
450 <a href="../fr/mod/mod_access_compat.html" hreflang="fr" rel="alternate" title="Français"> fr </a> |
451 <a href="../ja/mod/mod_access_compat.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a></p>
452 </div><div id="footer">
453 <p class="apache">Copyright 2009 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
454 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div>