]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_access_compat.xml
Rebuild.
[apache] / docs / manual / mod / mod_access_compat.xml
1 <?xml version="1.0"?>
2 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
4 <!-- $LastChangedRevision$ -->
5
6 <!--
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
13
14      http://www.apache.org/licenses/LICENSE-2.0
15
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.
21 -->
22
23 <modulesynopsis metafile="mod_access_compat.xml.meta">
24
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>
35
36 <summary>
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
53     other.</p>
54
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>
59
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
67       <directive
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
72       information.
73       </p>
74       </note>
75
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>
82
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>
87     </note>
88
89 </summary>
90
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>
94
95 <directivesynopsis>
96 <name>Allow</name>
97 <description>Controls which hosts can access an area of the
98 server</description>
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>
102 </contextlist>
103 <override>Limit</override>
104
105 <usage>
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
110     variables.</p>
111
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>
121
122     <dl>
123       <dt>A (partial) domain-name</dt>
124
125       <dd>
126       <highlight language="config">
127 Allow from example.org
128 Allow from .net example.edu
129       </highlight>
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>
142
143       <dt>A full IP address</dt>
144
145       <dd>
146       <highlight language="config">
147 Allow from 10.1.2.3
148 Allow from 192.168.1.104 192.168.1.205
149       </highlight>
150       <p>An IP address of a host allowed access</p></dd>
151
152       <dt>A partial IP address</dt>
153
154       <dd>
155       <highlight language="config">
156 Allow from 10.1
157 Allow from 10 172.20 192.168.2
158       </highlight>
159       <p>The first 1 to 3 bytes of an IP address, for subnet
160       restriction.</p></dd>
161
162       <dt>A network/netmask pair</dt>
163
164       <dd>
165       <highlight language="config">
166         Allow from 10.1.0.0/255.255.0.0
167       </highlight>
168       <p>A network a.b.c.d, and a netmask w.x.y.z. For more
169       fine-grained subnet restriction.</p></dd>
170
171       <dt>A network/nnn CIDR specification</dt>
172
173       <dd>
174       <highlight language="config">
175         Allow from 10.1.0.0/16
176       </highlight>
177       <p>Similar to the previous case, except the netmask consists of
178       nnn high-order 1 bits.</p></dd>
179     </dl>
180
181     <p>Note that the last three examples above match exactly the
182     same set of hosts.</p>
183
184     <p>IPv6 addresses and IPv6 subnets can be specified as shown
185     below:</p>
186
187     <highlight language="config">
188 Allow from 2001:db8::a00:20ff:fea7:ccea
189 Allow from 2001:db8::a00:20ff:fea7:ccea/10
190     </highlight>
191
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>
208
209     <highlight language="config">
210 SetEnvIf User-Agent ^KnockKnock/2\.0 let_me_in
211 &lt;Directory "/docroot"&gt;
212     Order Deny,Allow
213     Deny from all
214     Allow from env=let_me_in
215 &lt;/Directory&gt;
216     </highlight>
217
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>
221
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>
226     </note>
227
228 </usage>
229 </directivesynopsis>
230
231 <directivesynopsis>
232 <name>Deny</name>
233 <description>Controls which hosts are denied access to the
234 server</description>
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>
238 </contextlist>
239 <override>Limit</override>
240
241 <usage>
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>
247 </usage>
248 </directivesynopsis>
249
250 <directivesynopsis>
251 <name>Order</name>
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>
258 </contextlist>
259 <override>Limit</override>
260
261 <usage>
262
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
275     two.</p>
276
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>
288
289     <p><em>Ordering</em> is one of:</p>
290
291     <dl>
292       <dt><code>Allow,Deny</code></dt>
293
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
302       by default.</dd>
303
304       <dt><code>Deny,Allow</code></dt>
305
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
314       permitted.</dd>
315
316       <dt><code>Mutual-failure</code></dt>
317
318       <dd>This order has the same effect as <code>Order
319       Allow,Deny</code> and is deprecated in its favor.</dd>
320     </dl>
321
322     <p>Keywords may only be separated by a comma; <em>no whitespace</em>
323     is allowed between them.</p>
324
325     <table border="1">
326       <tr>
327         <th>Match</th>
328         <th>Allow,Deny result</th>
329         <th>Deny,Allow result</th>
330       </tr><tr>
331         <th>Match Allow only</th>
332         <td>Request allowed</td>
333         <td>Request allowed</td>
334       </tr><tr>
335         <th>Match Deny only</th>
336         <td>Request denied</td>
337         <td>Request denied</td>
338       </tr><tr>
339         <th>No match</th>
340         <td>Default to second directive: Denied</td>
341         <td>Default to second directive: Allowed</td>
342       </tr><tr>
343         <th>Match both Allow &amp; Deny</th>
344         <td>Final match controls: Denied</td>
345         <td>Final match controls: Allowed</td>
346       </tr>
347     </table>
348
349     <p>In the following example, all hosts in the example.org domain
350     are allowed access; all other hosts are denied access.</p>
351
352     <highlight language="config">
353 Order Deny,Allow
354 Deny from all
355 Allow from example.org
356     </highlight>
357
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>
364
365     <highlight language="config">
366 Order Allow,Deny
367 Allow from example.org
368 Deny from foo.example.org
369     </highlight>
370
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>
380
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
386     example,</p>
387
388     <highlight language="config">
389 &lt;Directory "/www"&gt;
390     Order Allow,Deny
391 &lt;/Directory&gt;
392     </highlight>
393
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>
397
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
412     work</a>.</p>
413
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>
418     </note>
419
420 </usage>
421 </directivesynopsis>
422
423 <directivesynopsis>
424 <name>Satisfy</name>
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>
430 </contextlist>
431 <override>AuthConfig</override>
432
433 <usage>
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>
447
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>
452
453     <highlight language="config">
454 Require valid-user
455 Allow from 192.168.1
456 Satisfy Any
457     </highlight>
458
459     <p>
460     Another frequent use of the <directive>Satisfy</directive> directive
461     is to relax access restrictions for a subdirectory:
462     </p>
463
464     <highlight language="config">
465 &lt;Directory "/var/www/private"&gt;
466     Require valid-user
467 &lt;/Directory&gt;
468
469 &lt;Directory "/var/www/private/public"&gt;
470     Allow from all
471     Satisfy Any
472 &lt;/Directory&gt;
473     </highlight>
474
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>
478
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>
483
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>
488     </note>
489
490 </usage>
491    <seealso><directive module="mod_access_compat">Allow</directive></seealso>
492    <seealso><directive module="mod_authz_core">Require</directive></seealso>
493 </directivesynopsis>
494
495 </modulesynopsis>