]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_authz_host.html.en
update transformation - en
[apache] / docs / manual / mod / mod_authz_host.html.en
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
7       -->
8 <title>mod_authz_host - 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>
13 <body>
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.1</p>
17 <img alt="" src="../images/feather.gif" /></div>
18 <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="../images/left.gif" /></a></div>
19 <div id="path">
20 <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs-project/">Documentation</a> &gt; <a href="../">Version 2.1</a> &gt; <a href="./">Modules</a></div>
21 <div id="page-content">
22 <div id="preamble"><h1>Apache Module mod_authz_host</h1>
23 <div class="toplang">
24 <p><span>Available Languages: </span><a href="../en/mod/mod_authz_host.html" hreflang="en" title="English">&nbsp;en&nbsp;</a> | <a href="../ja/mod/mod_authz_host.html" hreflang="ja" title="Japanese">&nbsp;ja&nbsp;</a></p>
25 </div>
26 <table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Group authorizations based on host (name or IP
27 address)</td></tr>
28 <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Base</td></tr>
29 <tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>authz_host_module</td></tr>
30 <tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>mod_authz_host.c</td></tr>
31 <tr><th><a href="module-dict.html#Compatibility">Compatibility:</a></th><td>Available in Apache 2.1 and later</td></tr></table>
32 <h3>Summary</h3>
33
34     <p>The directives provided by <code class="module"><a href="../mod/mod_authz_host.html">mod_authz_host</a></code> are
35     used in <code class="directive"><a href="../mod/core.html#directory">&lt;Directory&gt;</a></code>,
36     <code class="directive"><a href="../mod/core.html#files">&lt;Files&gt;</a></code>, and
37     <code class="directive"><a href="../mod/core.html#location">&lt;Location&gt;</a></code> sections
38     as well as <code><a href="core.html#accessfilename">.htaccess</a>
39     </code> files to control access to particular parts of the server.
40     Access can be controlled based on the client hostname, IP address, or
41     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
42     specify which clients are or are not allowed access to the server,
43     while the <code class="directive"><a href="#order">Order</a></code>
44     directive sets the default access state, and configures how the
45     <code class="directive"><a href="#allow">Allow</a></code> and <code class="directive"><a href="#deny">Deny</a></code> directives interact with each
46     other.</p>
47
48     <p>Both host-based access restrictions and password-based
49     authentication may be implemented simultaneously. In that case,
50     the <code class="directive"><a href="../mod/core.html#satisfy">Satisfy</a></code> directive is used
51     to determine how the two sets of restrictions interact.</p>
52
53     <p>In general, access restriction directives apply to all
54     access methods (<code>GET</code>, <code>PUT</code>,
55     <code>POST</code>, etc). This is the desired behavior in most
56     cases. However, it is possible to restrict some methods, while
57     leaving other methods unrestricted, by enclosing the directives
58     in a <code class="directive"><a href="../mod/core.html#limit">&lt;Limit&gt;</a></code> section.</p>
59 </div>
60 <div id="quickview"><h3 class="directives">Directives</h3>
61 <ul id="toc">
62 <li><img alt="" src="../images/down.gif" /> <a href="#allow">Allow</a></li>
63 <li><img alt="" src="../images/down.gif" /> <a href="#deny">Deny</a></li>
64 <li><img alt="" src="../images/down.gif" /> <a href="#order">Order</a></li>
65 </ul>
66 <h3>See also</h3>
67 <ul class="seealso">
68 <li><code class="directive"><a href="../mod/core.html#satisfy">Satisfy</a></code></li>
69 <li><code class="directive"><a href="../mod/core.html#require">Require</a></code></li>
70 </ul></div>
71
72 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
73 <div class="directive-section"><h2><a name="Allow" id="Allow">Allow</a> <a name="allow" id="allow">Directive</a></h2>
74 <table class="directive">
75 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Controls which hosts can access an area of the
76 server</td></tr>
77 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code> Allow from all|<var>host</var>|env=<var>env-variable</var>
78 [<var>host</var>|env=<var>env-variable</var>] ...</code></td></tr>
79 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory, .htaccess</td></tr>
80 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>Limit</td></tr>
81 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
82 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_authz_host</td></tr>
83 </table>
84     <p>The <code class="directive">Allow</code> directive affects which hosts can
85     access an area of the server. Access can be controlled by
86     hostname, IP Address, IP Address range, or by other
87     characteristics of the client request captured in environment
88     variables.</p>
89
90     <p>The first argument to this directive is always
91     <code>from</code>. The subsequent arguments can take three
92     different forms. If <code>Allow from all</code> is specified, then
93     all hosts are allowed access, subject to the configuration of the
94     <code class="directive"><a href="#deny">Deny</a></code> and <code class="directive"><a href="#order">Order</a></code> directives as discussed
95     below. To allow only particular hosts or groups of hosts to access
96     the server, the <em>host</em> can be specified in any of the
97     following formats:</p>
98
99     <dl>
100       <dt>A (partial) domain-name</dt>
101
102       <dd>
103       <div class="example"><h3>Example:</h3><p><code>
104         Allow from apache.org
105       </code></p></div>
106       <p>Hosts whose names match, or end in, this string are allowed
107       access. Only complete components are matched, so the above
108       example will match <code>foo.apache.org</code> but it will
109       not match <code>fooapache.org</code>. This configuration will
110       cause the server to perform a reverse DNS lookup on the
111       client IP address, regardless of the setting of the <code class="directive"><a href="../mod/core.html#hostnamelookups">HostnameLookups</a></code>
112       directive.</p></dd>
113
114       <dt>A full IP address</dt>
115
116       <dd>
117       <div class="example"><h3>Example:</h3><p><code>
118         Allow from 10.1.2.3
119       </code></p></div>
120       <p>An IP address of a host allowed access</p></dd>
121
122       <dt>A partial IP address</dt>
123
124       <dd>
125       <div class="example"><h3>Example:</h3><p><code>
126         Allow from 10.1
127       </code></p></div>
128       <p>The first 1 to 3 bytes of an IP address, for subnet
129       restriction.</p></dd>
130
131       <dt>A network/netmask pair</dt>
132
133       <dd>
134       <div class="example"><h3>Example:</h3><p><code>
135         Allow from 10.1.0.0/255.255.0.0
136       </code></p></div>
137       <p>A network a.b.c.d, and a netmask w.x.y.z. For more
138       fine-grained subnet restriction.</p></dd>
139
140       <dt>A network/nnn CIDR specification</dt>
141
142       <dd>
143       <div class="example"><h3>Example:</h3><p><code>
144         Allow from 10.1.0.0/16
145       </code></p></div>
146       <p>Similar to the previous case, except the netmask consists of
147       nnn high-order 1 bits.</p></dd>
148     </dl>
149
150     <p>Note that the last three examples above match exactly the
151     same set of hosts.</p>
152
153     <p>IPv6 addresses and IPv6 subnets can be specified as shown
154     below:</p>
155
156     <div class="example"><p><code>
157        Allow from fe80::a00:20ff:fea7:ccea<br />
158        Allow from fe80::a00:20ff:fea7:ccea/10
159     </code></p></div>
160
161     <p>The third format of the arguments to the
162     <code class="directive">Allow</code> directive allows access to the server
163     to be controlled based on the existence of an <a href="../env.html">environment variable</a>. When <code>Allow from
164     env=<var>env-variable</var></code> is specified, then the request is
165     allowed access if the environment variable <var>env-variable</var>
166     exists. The server provides the ability to set environment
167     variables in a flexible way based on characteristics of the client
168     request using the directives provided by
169     <code class="module"><a href="../mod/mod_setenvif.html">mod_setenvif</a></code>. Therefore, this directive can be
170     used to allow access based on such factors as the clients
171     <code>User-Agent</code> (browser type), <code>Referer</code>, or
172     other HTTP request header fields.</p>
173
174     <div class="example"><h3>Example:</h3><p><code>
175       SetEnvIf User-Agent ^KnockKnock/2.0 let_me_in<br />
176       &lt;Directory /docroot&gt;<br />
177       <span class="indent">
178         Order Deny,Allow<br />
179         Deny from all<br />
180         Allow from env=let_me_in<br />
181       </span>
182       &lt;/Directory&gt;
183     </code></p></div>
184
185     <p>In this case, browsers with a user-agent string beginning
186     with <code>KnockKnock/2.0</code> will be allowed access, and all
187     others will be denied.</p>
188
189 </div>
190 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
191 <div class="directive-section"><h2><a name="Deny" id="Deny">Deny</a> <a name="deny" id="deny">Directive</a></h2>
192 <table class="directive">
193 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Controls which hosts are denied access to the
194 server</td></tr>
195 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code> Deny from all|<var>host</var>|env=<var>env-variable</var>
196 [<var>host</var>|env=<var>env-variable</var>] ...</code></td></tr>
197 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory, .htaccess</td></tr>
198 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>Limit</td></tr>
199 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
200 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_authz_host</td></tr>
201 </table>
202     <p>This directive allows access to the server to be restricted
203     based on hostname, IP address, or environment variables. The
204     arguments for the <code class="directive">Deny</code> directive are
205     identical to the arguments for the <code class="directive"><a href="#allow">Allow</a></code> directive.</p>
206
207 </div>
208 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
209 <div class="directive-section"><h2><a name="Order" id="Order">Order</a> <a name="order" id="order">Directive</a></h2>
210 <table class="directive">
211 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Controls the default access state and the order in which
212 Allow and Deny are
213 evaluated.</td></tr>
214 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code> Order <var>ordering</var></code></td></tr>
215 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>Order Deny,Allow</code></td></tr>
216 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory, .htaccess</td></tr>
217 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>Limit</td></tr>
218 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
219 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_authz_host</td></tr>
220 </table>
221     <p>The <code class="directive">Order</code> directive controls the default
222     access state and the order in which <code class="directive"><a href="#allow">Allow</a></code> and <code class="directive"><a href="#deny">Deny</a></code> directives are evaluated.
223     <var>Ordering</var> is one of</p>
224
225     <dl>
226       <dt><code>Deny,Allow</code></dt>
227
228       <dd>The <code class="directive"><a href="#deny">Deny</a></code> directives
229       are evaluated before the <code class="directive"><a href="#allow">Allow</a></code> directives. Access is
230       allowed by default. Any client which does not match a
231       <code class="directive"><a href="#deny">Deny</a></code> directive or does
232       match an <code class="directive"><a href="#allow">Allow</a></code>
233       directive will be allowed access to the server.</dd>
234
235       <dt><code>Allow,Deny</code></dt>
236
237       <dd>The <code class="directive"><a href="#allow">Allow</a></code>
238       directives are evaluated before the <code class="directive"><a href="#deny">Deny</a></code> directives. Access is denied
239       by default. Any client which does not match an <code class="directive"><a href="#allow">Allow</a></code> directive or does match a
240       <code class="directive"><a href="#deny">Deny</a></code> directive will be
241       denied access to the server.</dd>
242
243       <dt><code>Mutual-failure</code></dt>
244
245       <dd>Only those hosts which appear on the <code class="directive"><a href="#allow">Allow</a></code> list and do not appear on
246       the <code class="directive"><a href="#deny">Deny</a></code> list are
247       granted access. This ordering has the same effect as <code>Order
248       Allow,Deny</code> and is deprecated in favor of that
249       configuration.</dd>
250     </dl>
251
252     <p>Keywords may only be separated by a comma; <em>no whitespace</em> is
253     allowed between them. Note that in all cases every <code class="directive"><a href="#allow">Allow</a></code> and <code class="directive"><a href="#deny">Deny</a></code> statement is evaluated.</p>
254
255     <p>In the following example, all hosts in the apache.org domain
256     are allowed access; all other hosts are denied access.</p>
257
258     <div class="example"><p><code>
259       Order Deny,Allow<br />
260       Deny from all<br />
261       Allow from apache.org
262     </code></p></div>
263
264     <p>In the next example, all hosts in the apache.org domain are
265     allowed access, except for the hosts which are in the
266     foo.apache.org subdomain, who are denied access. All hosts not
267     in the apache.org domain are denied access because the default
268     state is to deny access to the server.</p>
269
270     <div class="example"><p><code>
271       Order Allow,Deny<br />
272       Allow from apache.org<br />
273       Deny from foo.apache.org
274     </code></p></div>
275
276     <p>On the other hand, if the <code class="directive">Order</code> in the last
277     example is changed to <code>Deny,Allow</code>, all hosts will
278     be allowed access. This happens because, regardless of the
279     actual ordering of the directives in the configuration file,
280     the <code>Allow from apache.org</code> will be evaluated last
281     and will override the <code>Deny from foo.apache.org</code>.
282     All hosts not in the <code>apache.org</code> domain will also
283     be allowed access because the default state will change to
284     <em>allow</em>.</p>
285
286     <p>The presence of an <code class="directive">Order</code> directive can affect
287     access to a part of the server even in the absence of accompanying
288     <code class="directive"><a href="#allow">Allow</a></code> and <code class="directive"><a href="#deny">Deny</a></code> directives because of its effect
289     on the default access state. For example,</p>
290
291     <div class="example"><p><code>
292       &lt;Directory /www&gt;<br />
293       <span class="indent">
294         Order Allow,Deny<br />
295       </span>
296       &lt;/Directory&gt;
297     </code></p></div>
298
299     <p>will deny all access to the <code>/www</code> directory
300     because the default access state will be set to
301     <em>deny</em>.</p>
302
303     <p>The <code class="directive">Order</code> directive controls the order of access
304     directive processing only within each phase of the server's
305     configuration processing. This implies, for example, that an
306     <code class="directive"><a href="#allow">Allow</a></code> or <code class="directive"><a href="#deny">Deny</a></code> directive occurring in a
307     <code class="directive"><a href="../mod/core.html#location">&lt;Location&gt;</a></code> section will
308     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
309     <code class="directive"><a href="../mod/core.html#directory">&lt;Directory&gt;</a></code> section or
310     <code>.htaccess</code> file, regardless of the setting of the
311     <code class="directive">Order</code> directive. For details on the merging
312     of configuration sections, see the documentation on <a href="../sections.html">How Directory, Location and Files sections
313     work</a>.</p>
314
315 </div>
316 </div>
317 <div class="bottomlang">
318 <p><span>Available Languages: </span><a href="../en/mod/mod_authz_host.html" hreflang="en" title="English">&nbsp;en&nbsp;</a> | <a href="../ja/mod/mod_authz_host.html" hreflang="ja" title="Japanese">&nbsp;ja&nbsp;</a></p>
319 </div><div id="footer">
320 <p class="apache">Maintained by the <a href="http://httpd.apache.org/docs-project/">Apache HTTP Server Documentation Project</a></p>
321 <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>
322 </body></html>