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