2 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
4 <!-- $LastChangedRevision$ -->
7 Licensed to the Apache Software Foundation (ASF) under one or more
8 contributor license agreements. See the NOTICE file distributed with
9 this work for additional information regarding copyright ownership.
10 The ASF licenses this file to You under the Apache License, Version 2.0
11 (the "License"); you may not use this file except in compliance with
12 the License. You may obtain a copy of the License at
14 http://www.apache.org/licenses/LICENSE-2.0
16 Unless required by applicable law or agreed to in writing, software
17 distributed under the License is distributed on an "AS IS" BASIS,
18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 See the License for the specific language governing permissions and
20 limitations under the License.
23 <modulesynopsis metafile="mod_access_compat.xml.meta">
25 <name>mod_access_compat</name>
26 <description>Group authorizations based on host (name or IP
27 address)</description>
28 <status>Extension</status>
29 <sourcefile>mod_access_compat.c</sourcefile>
30 <identifier>access_compat_module</identifier>
31 <compatibility>Available in Apache HTTP Server 2.3 as a compatibility module with
32 previous versions of Apache httpd 2.x. The directives provided by this module
33 have been deprecated by the new authz refactoring. Please see
34 <module>mod_authz_host</module></compatibility>
37 <p>The directives provided by <module>mod_access_compat</module> are
38 used in <directive module="core" type="section">Directory</directive>,
39 <directive module="core" type="section">Files</directive>, and
40 <directive module="core" type="section">Location</directive> sections
41 as well as <code><a href="core.html#accessfilename">.htaccess</a>
42 </code> files to control access to particular parts of the server.
43 Access can be controlled based on the client hostname, IP address, or
44 other characteristics of the client request, as captured in <a
45 href="../env.html">environment variables</a>. The <directive
46 module="mod_access_compat">Allow</directive> and <directive
47 module="mod_access_compat">Deny</directive> directives are used to
48 specify which clients are or are not allowed access to the server,
49 while the <directive module="mod_access_compat">Order</directive>
50 directive sets the default access state, and configures how the
51 <directive module="mod_access_compat">Allow</directive> and <directive
52 module="mod_access_compat">Deny</directive> directives interact with each
55 <p>Both host-based access restrictions and password-based
56 authentication may be implemented simultaneously. In that case,
57 the <directive module="mod_access_compat">Satisfy</directive> directive is used
58 to determine how the two sets of restrictions interact.</p>
60 <note type="warning"><title>Note</title>
61 <p>The directives provided by <module>mod_access_compat</module> have
62 been deprecated by <module>mod_authz_host</module>.
63 Mixing old directives like <directive
64 module="mod_access_compat">Order</directive>, <directive
65 module="mod_access_compat">Allow</directive> or <directive
66 module="mod_access_compat">Deny</directive> with new ones like
68 module="mod_authz_core">Require</directive> is technically possible
69 but discouraged. This module was created to support
70 configurations containing only old directives to facilitate the 2.4 upgrade.
71 Please check the <a href="../upgrading.html">upgrading</a> guide for more
76 <p>In general, access restriction directives apply to all
77 access methods (<code>GET</code>, <code>PUT</code>,
78 <code>POST</code>, etc). This is the desired behavior in most
79 cases. However, it is possible to restrict some methods, while
80 leaving other methods unrestricted, by enclosing the directives
81 in a <directive module="core" type="section">Limit</directive> section.</p>
83 <note> <title>Merging of configuration sections</title>
84 <p>When any directive provided by this module is used in a new
85 configuration section, no directives provided by this module are
86 inherited from previous configuration sections.</p>
91 <seealso><directive module="mod_authz_core">Require</directive></seealso>
92 <seealso><module>mod_authz_host</module></seealso>
93 <seealso><module>mod_authz_core</module></seealso>
97 <description>Controls which hosts can access an area of the
99 <syntax> Allow from all|<var>host</var>|env=[!]<var>env-variable</var>
100 [<var>host</var>|env=[!]<var>env-variable</var>] ...</syntax>
101 <contextlist><context>directory</context><context>.htaccess</context>
103 <override>Limit</override>
106 <p>The <directive>Allow</directive> directive affects which hosts can
107 access an area of the server. Access can be controlled by
108 hostname, IP address, IP address range, or by other
109 characteristics of the client request captured in environment
112 <p>The first argument to this directive is always
113 <code>from</code>. The subsequent arguments can take three
114 different forms. If <code>Allow from all</code> is specified, then
115 all hosts are allowed access, subject to the configuration of the
116 <directive module="mod_access_compat">Deny</directive> and <directive
117 module="mod_access_compat">Order</directive> directives as discussed
118 below. To allow only particular hosts or groups of hosts to access
119 the server, the <em>host</em> can be specified in any of the
120 following formats:</p>
123 <dt>A (partial) domain-name</dt>
126 <highlight language="config">
127 Allow from example.org
128 Allow from .net example.edu
130 <p>Hosts whose names match, or end in, this string are allowed
131 access. Only complete components are matched, so the above
132 example will match <code>foo.example.org</code> but it will not
133 match <code>fooexample.org</code>. This configuration will cause
134 Apache httpd to perform a double DNS lookup on the client IP
135 address, regardless of the setting of the <directive
136 module="core">HostnameLookups</directive> directive. It will do
137 a reverse DNS lookup on the IP address to find the associated
138 hostname, and then do a forward lookup on the hostname to assure
139 that it matches the original IP address. Only if the forward
140 and reverse DNS are consistent and the hostname matches will
141 access be allowed.</p></dd>
143 <dt>A full IP address</dt>
146 <highlight language="config">
148 Allow from 192.168.1.104 192.168.1.205
150 <p>An IP address of a host allowed access</p></dd>
152 <dt>A partial IP address</dt>
155 <highlight language="config">
157 Allow from 10 172.20 192.168.2
159 <p>The first 1 to 3 bytes of an IP address, for subnet
160 restriction.</p></dd>
162 <dt>A network/netmask pair</dt>
165 <highlight language="config">
166 Allow from 10.1.0.0/255.255.0.0
168 <p>A network a.b.c.d, and a netmask w.x.y.z. For more
169 fine-grained subnet restriction.</p></dd>
171 <dt>A network/nnn CIDR specification</dt>
174 <highlight language="config">
175 Allow from 10.1.0.0/16
177 <p>Similar to the previous case, except the netmask consists of
178 nnn high-order 1 bits.</p></dd>
181 <p>Note that the last three examples above match exactly the
182 same set of hosts.</p>
184 <p>IPv6 addresses and IPv6 subnets can be specified as shown
187 <highlight language="config">
188 Allow from 2001:db8::a00:20ff:fea7:ccea
189 Allow from 2001:db8::a00:20ff:fea7:ccea/10
192 <p>The third format of the arguments to the
193 <directive>Allow</directive> directive allows access to the server
194 to be controlled based on the existence of an <a
195 href="../env.html">environment variable</a>. When <code>Allow from
196 env=<var>env-variable</var></code> is specified, then the request is
197 allowed access if the environment variable <var>env-variable</var>
198 exists. When <code>Allow from env=!<var>env-variable</var></code> is
199 specified, then the request is allowed access if the environment
200 variable <var>env-variable</var> doesn't exist.
201 The server provides the ability to set environment
202 variables in a flexible way based on characteristics of the client
203 request using the directives provided by
204 <module>mod_setenvif</module>. Therefore, this directive can be
205 used to allow access based on such factors as the clients
206 <code>User-Agent</code> (browser type), <code>Referer</code>, or
207 other HTTP request header fields.</p>
209 <highlight language="config">
210 SetEnvIf User-Agent ^KnockKnock/2\.0 let_me_in
211 <Directory "/docroot">
214 Allow from env=let_me_in
218 <p>In this case, browsers with a user-agent string beginning
219 with <code>KnockKnock/2.0</code> will be allowed access, and all
220 others will be denied.</p>
222 <note> <title>Merging of configuration sections</title>
223 <p>When any directive provided by this module is used in a new
224 configuration section, no directives provided by this module are
225 inherited from previous configuration sections.</p>
233 <description>Controls which hosts are denied access to the
235 <syntax> Deny from all|<var>host</var>|env=[!]<var>env-variable</var>
236 [<var>host</var>|env=[!]<var>env-variable</var>] ...</syntax>
237 <contextlist><context>directory</context><context>.htaccess</context>
239 <override>Limit</override>
242 <p>This directive allows access to the server to be restricted
243 based on hostname, IP address, or environment variables. The
244 arguments for the <directive>Deny</directive> directive are
245 identical to the arguments for the <directive
246 module="mod_access_compat">Allow</directive> directive.</p>
252 <description>Controls the default access state and the order in which
253 <directive>Allow</directive> and <directive>Deny</directive> are
254 evaluated.</description>
255 <syntax> Order <var>ordering</var></syntax>
256 <default>Order Deny,Allow</default>
257 <contextlist><context>directory</context><context>.htaccess</context>
259 <override>Limit</override>
263 <p>The <directive>Order</directive> directive, along with the
264 <directive module="mod_access_compat">Allow</directive> and
265 <directive module="mod_access_compat">Deny</directive> directives,
266 controls a three-pass access control system. The first pass
267 processes either all <directive
268 module="mod_access_compat">Allow</directive> or all <directive
269 module="mod_access_compat">Deny</directive> directives, as specified
270 by the <directive module="mod_access_compat">Order</directive>
271 directive. The second pass parses the rest of the directives
272 (<directive module="mod_access_compat">Deny</directive> or
273 <directive module="mod_access_compat">Allow</directive>). The third
274 pass applies to all requests which do not match either of the first
277 <p>Note that all <directive
278 module="mod_access_compat">Allow</directive> and <directive
279 module="mod_access_compat">Deny</directive> directives are
280 processed, unlike a typical firewall, where only the first match is
281 used. The last match is effective (also unlike a typical firewall).
282 Additionally, the order in which lines appear in the configuration
283 files is not significant -- all <directive
284 module="mod_access_compat">Allow</directive> lines are processed as
285 one group, all <directive
286 module="mod_access_compat">Deny</directive> lines are considered as
287 another, and the default state is considered by itself.</p>
289 <p><em>Ordering</em> is one of:</p>
292 <dt><code>Allow,Deny</code></dt>
294 <dd>First, all <directive
295 module="mod_access_compat">Allow</directive> directives are
296 evaluated; at least one must match, or the request is rejected.
297 Next, all <directive module="mod_access_compat">Deny</directive>
298 directives are evaluated. If any matches, the request is rejected.
299 Last, any requests which do not match an <directive
300 module="mod_access_compat">Allow</directive> or a <directive
301 module="mod_access_compat">Deny</directive> directive are denied
304 <dt><code>Deny,Allow</code></dt>
306 <dd>First, all <directive
307 module="mod_access_compat">Deny</directive> directives are
308 evaluated; if any match, the request is denied
309 <strong>unless</strong> it also matches an <directive
310 module="mod_access_compat">Allow</directive> directive. Any
311 requests which do not match any <directive
312 module="mod_access_compat">Allow</directive> or <directive
313 module="mod_access_compat">Deny</directive> directives are
316 <dt><code>Mutual-failure</code></dt>
318 <dd>This order has the same effect as <code>Order
319 Allow,Deny</code> and is deprecated in its favor.</dd>
322 <p>Keywords may only be separated by a comma; <em>no whitespace</em>
323 is allowed between them.</p>
328 <th>Allow,Deny result</th>
329 <th>Deny,Allow result</th>
331 <th>Match Allow only</th>
332 <td>Request allowed</td>
333 <td>Request allowed</td>
335 <th>Match Deny only</th>
336 <td>Request denied</td>
337 <td>Request denied</td>
340 <td>Default to second directive: Denied</td>
341 <td>Default to second directive: Allowed</td>
343 <th>Match both Allow & Deny</th>
344 <td>Final match controls: Denied</td>
345 <td>Final match controls: Allowed</td>
349 <p>In the following example, all hosts in the example.org domain
350 are allowed access; all other hosts are denied access.</p>
352 <highlight language="config">
355 Allow from example.org
358 <p>In the next example, all hosts in the example.org domain are
359 allowed access, except for the hosts which are in the
360 foo.example.org subdomain, who are denied access. All hosts not
361 in the example.org domain are denied access because the default
362 state is to <directive module="mod_access_compat">Deny</directive>
363 access to the server.</p>
365 <highlight language="config">
367 Allow from example.org
368 Deny from foo.example.org
371 <p>On the other hand, if the <directive>Order</directive> in the
372 last example is changed to <code>Deny,Allow</code>, all hosts will
373 be allowed access. This happens because, regardless of the actual
374 ordering of the directives in the configuration file, the
375 <code>Allow from example.org</code> will be evaluated last and will
376 override the <code>Deny from foo.example.org</code>. All hosts not in
377 the <code>example.org</code> domain will also be allowed access
378 because the default state is <directive
379 module="mod_access_compat">Allow</directive>.</p>
381 <p>The presence of an <directive>Order</directive> directive can
382 affect access to a part of the server even in the absence of
383 accompanying <directive module="mod_access_compat">Allow</directive>
384 and <directive module="mod_access_compat">Deny</directive>
385 directives because of its effect on the default access state. For
388 <highlight language="config">
389 <Directory "/www">
394 <p>will Deny all access to the <code>/www</code> directory
395 because the default access state is set to
396 <directive module="mod_access_compat">Deny</directive>.</p>
398 <p>The <directive>Order</directive> directive controls the order of access
399 directive processing only within each phase of the server's
400 configuration processing. This implies, for example, that an
401 <directive module="mod_access_compat">Allow</directive> or <directive
402 module="mod_access_compat">Deny</directive> directive occurring in a
403 <directive module="core" type="section">Location</directive> section will
404 always be evaluated after an <directive
405 module="mod_access_compat">Allow</directive> or <directive
406 module="mod_access_compat">Deny</directive> directive occurring in a
407 <directive module="core" type="section">Directory</directive> section or
408 <code>.htaccess</code> file, regardless of the setting of the
409 <directive>Order</directive> directive. For details on the merging
410 of configuration sections, see the documentation on <a
411 href="../sections.html">How Directory, Location and Files sections
414 <note> <title>Merging of configuration sections</title>
415 <p>When any directive provided by this module is used in a new
416 configuration section, no directives provided by this module are
417 inherited from previous configuration sections.</p>
425 <description>Interaction between host-level access control and
426 user authentication</description>
427 <syntax>Satisfy Any|All</syntax>
428 <default>Satisfy All</default>
429 <contextlist><context>directory</context><context>.htaccess</context>
431 <override>AuthConfig</override>
434 <p>Access policy if both <directive
435 module="mod_access_compat">Allow</directive> and <directive
436 module="mod_authz_core">Require</directive> used. The parameter can be
437 either <code>All</code> or <code>Any</code>. This directive is only
438 useful if access to a particular area is being restricted by both
439 username/password <em>and</em> client host address. In this case
440 the default behavior (<code>All</code>) is to require that the client
441 passes the address access restriction <em>and</em> enters a valid
442 username and password. With the <code>Any</code> option the client will be
443 granted access if they either pass the host restriction or enter a
444 valid username and password. This can be used to password restrict
445 an area, but to let clients from particular addresses in without
446 prompting for a password.</p>
448 <p>For example, if you wanted to let people on your network have
449 unrestricted access to a portion of your website, but require that
450 people outside of your network provide a password, you could use a
451 configuration similar to the following:</p>
453 <highlight language="config">
460 Another frequent use of the <directive>Satisfy</directive> directive
461 is to relax access restrictions for a subdirectory:
464 <highlight language="config">
465 <Directory "/var/www/private">
469 <Directory "/var/www/private/public">
475 <p>In the above example, authentication will be required for the
476 <code>/var/www/private</code> directory, but will not be required
477 for the <code>/var/www/private/public</code> directory.</p>
479 <p>Since version 2.0.51 <directive>Satisfy</directive> directives can
480 be restricted to particular methods by <directive module="core"
481 type="section">Limit</directive> and <directive module="core" type="section"
482 >LimitExcept</directive> sections.</p>
484 <note> <title>Merging of configuration sections</title>
485 <p>When any directive provided by this module is used in a new
486 configuration section, no directives provided by this module are
487 inherited from previous configuration sections.</p>
491 <seealso><directive module="mod_access_compat">Allow</directive></seealso>
492 <seealso><directive module="mod_authz_core">Require</directive></seealso>