summaryrefslogtreecommitdiff
path: root/usr.sbin/httpd/htdocs/manual/mod/mod_access.html
blob: babc2923db270c5e18702e9ff8cc9f1c7ba55584 (plain)
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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>Apache module mod_access</TITLE>
</HEAD>

<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
<BODY
 BGCOLOR="#FFFFFF"
 TEXT="#000000"
 LINK="#0000FF"
 VLINK="#000080"
 ALINK="#FF0000"
>
<DIV ALIGN="CENTER">
 <IMG SRC="../images/sub.gif" ALT="[APACHE DOCUMENTATION]">
 <H3>
  Apache HTTP Server Version 1.3
 </H3>
</DIV>


<H1 ALIGN="CENTER">Module mod_access</H1>
<P>
This module provides access control based on client hostname or IP
address.
</P>

<P><A
HREF="module-dict.html#Status"
REL="Help"
><STRONG>Status:</STRONG></A> Base
<BR>
<A
HREF="module-dict.html#SourceFile"
REL="Help"
><STRONG>Source File:</STRONG></A> mod_access.c
<BR>
<A
HREF="module-dict.html#ModuleIdentifier"
REL="Help"
><STRONG>Module Identifier:</STRONG></A> access_module
</P>


<H2>Directives</H2>

<UL>
<LI><A HREF="#allow">Allow</A>
<LI><A HREF="#allowfromenv">Allow from env=</A>
<LI><A HREF="#deny">Deny</A>
<LI><A HREF="#denyfromenv">Deny from env=</A>
<LI><A HREF="#order">Order</A>
</UL>

<P>See also <A HREF="core.html#satisfy">Satisfy</A>
    and <A HREF="core.html#require">Require</A>.

<HR>


<H2><A NAME="allow">Allow directive</A></H2>
<P>
<!--%plaintext &lt;?INDEX {\tt Allow} directive&gt; -->
<A
 HREF="directive-dict.html#Syntax"
 REL="Help"
><STRONG>Syntax:</STRONG></A> Allow from <EM>host host ...</EM><BR>
<A
 HREF="directive-dict.html#Context"
 REL="Help"
><STRONG>Context:</STRONG></A> directory, .htaccess<BR>
<A
 HREF="directive-dict.html#Override"
 REL="Help"
><STRONG>Override:</STRONG></A> Limit<BR>
<A
 HREF="directive-dict.html#Status"
 REL="Help"
><STRONG>Status:</STRONG></A> Base<BR>
<A
 HREF="directive-dict.html#Module"
 REL="Help"
><STRONG>Module:</STRONG></A> mod_access
</P>
<P>
The Allow directive affects which hosts can access a given directory.
<EM>Host</EM> is one of the following:
</P>
<DL>
<DT><CODE>all</CODE>
<DD>All hosts are allowed access
<DT>A (partial) domain-name
<DD>Hosts whose names match, or end in, this string are allowed access.
<DT>A full IP address
<DD>An IP address of a host allowed access
<DT>A partial IP address
<DD>The first 1 to 3 bytes of an IP address, for subnet restriction.
<DT>A network/netmask pair (<STRONG>Apache 1.3 and later</STRONG>)
<DD>A network a.b.c.d, and a netmask w.x.y.z.  For more fine-grained subnet
    restriction.  (<EM>i.e.</EM>, 10.1.0.0/255.255.0.0)
<DT>A network/nnn CIDR specification (<STRONG>Apache 1.3 and later</STRONG>)
<DD>Similar to the previous case, except the netmask consists of nnn 
    high-order 1 bits.  (<EM>i.e.</EM>, 10.1.0.0/16 is the same as 10.1.0.0/255.255.0.0)
</DL>
<P>
Example:
</P>
<BLOCKQUOTE><CODE>Allow from .ncsa.uiuc.edu</CODE></BLOCKQUOTE>
<P>
All hosts in the specified domain are allowed access.
</P>
<P>
Note that this compares whole components; <CODE>bar.edu</CODE>
would not match <CODE>foobar.edu</CODE>.
</P>
<P>
See also <A HREF="#allowfromenv">Allow from env=</A>, <A
HREF="#deny">Deny</A> and <A HREF="#order">Order</A>.
</P>

<HR>

<H2><A NAME="allowfromenv">Allow from env= directive</A></H2>

<P>
<STRONG>Syntax:</STRONG> Allow from
 env=<EM>variablename</EM><BR>
<A
 HREF="directive-dict.html#Context"
 REL="Help"
><STRONG>Context:</STRONG></A> directory, .htaccess<BR>
<A
 HREF="directive-dict.html#Override"
 REL="Help"
><STRONG>Override:</STRONG></A> Limit<BR>
<A
 HREF="directive-dict.html#Status"
 REL="Help"
><STRONG>Status:</STRONG></A> Base<BR>
<A
 HREF="directive-dict.html#Module"
 REL="Help"
><STRONG>Module:</STRONG></A> mod_access<BR>
<A
 HREF="directive-dict.html#Compatibility"
 REL="Help"
><STRONG>Compatibility:</STRONG></A> Apache 1.2 and above
</P>
<P>
The <CODE>Allow from env</CODE> directive controls access to a directory by the
existence (or non-existence) of an environment variable.
</P>
<P>
Example:
</P>
<BLOCKQUOTE><PRE>
SetEnvIf User-Agent ^KnockKnock/2.0 let_me_in
&lt;Directory /docroot&gt;
    Order Deny,Allow
    Deny from all
    Allow from env=let_me_in
&lt;/Directory&gt;
</PRE></BLOCKQUOTE>
In this case browsers with the user-agent string <TT>KnockKnock/2.0</TT> will
be allowed access, and all others will be denied.
<P>
See also <A HREF="#denyfromenv">Deny from env=</A>, <A HREF="#order">Order</A>
and <A HREF="mod_setenvif.html#SetEnvIf">SetEnvIf</A>.
</P>
<HR>

<H2><A NAME="deny">Deny directive</A></H2>
<P>
<!--%plaintext &lt;?INDEX {\tt Deny} directive&gt; -->
<A
 HREF="directive-dict.html#Syntax"
 REL="Help"
><STRONG>Syntax:</STRONG></A> Deny from <EM>host host ...</EM><BR>
<A
 HREF="directive-dict.html#Context"
 REL="Help"
><STRONG>Context:</STRONG></A> directory, .htaccess<BR>
<A
 HREF="directive-dict.html#Override"
 REL="Help"
><STRONG>Override:</STRONG></A> Limit<BR>
<A
 HREF="directive-dict.html#Status"
 REL="Help"
><STRONG>Status:</STRONG></A> Base<BR>
<A
 HREF="directive-dict.html#Module"
 REL="Help"
><STRONG>Module:</STRONG></A> mod_access
</P>
<P>
The <CODE>Deny</CODE> directive affects which hosts can access a given directory.
<EM>Host</EM> is one of the following:
</P>
<DL>
<DT><CODE>all</CODE>
<DD>all hosts are denied access
<DT>A (partial) domain-name
<DD>host whose name is, or ends in, this string are denied access.
<DT>A full IP address
<DD>An IP address of a host denied access
<DT>A partial IP address
<DD>The first 1 to 3 bytes of an IP address, for subnet restriction.
<DT>A network/netmask pair (<STRONG>Apache 1.3 and later</STRONG>)
<DD>A network a.b.c.d, and a netmask w.x.y.z.  For more fine-grained subnet
    restriction.  (<EM>i.e.</EM>, 10.1.0.0/255.255.0.0)
<DT>A network/nnn CIDR specification (<STRONG>Apache 1.3 and later</STRONG>)
<DD>Similar to the previous case, except the netmask consists of nnn 
    high-order 1 bits.  (<EM>i.e.</EM>, 10.1.0.0/16 is the same as 10.1.0.0/255.255.0.0)
</DL>
<P>
Example:
</P>
<BLOCKQUOTE><CODE>Deny from 16</CODE></BLOCKQUOTE>
<P>
All hosts in the specified network are denied access.
</P>
<P>
Note that this compares whole components; <CODE>bar.edu</CODE>
would not match <CODE>foobar.edu</CODE>.
</P>
<P>
See also <A HREF="#denyfromenv">Deny from env=</A>, <A
HREF="#allow">Allow</A> and <A HREF="#order">Order</A>.
</P>

<HR>

<H2><A NAME="denfromenv">Deny from env= directive</A></H2>

<P>
<STRONG>Syntax:</STRONG> Deny from
 env=<EM>variablename</EM><BR>
<A
 HREF="directive-dict.html#Context"
 REL="Help"
><STRONG>Context:</STRONG></A> directory, .htaccess<BR>
<A
 HREF="directive-dict.html#Override"
 REL="Help"
><STRONG>Override:</STRONG></A> Limit<BR>
<A
 HREF="directive-dict.html#Status"
 REL="Help"
><STRONG>Status:</STRONG></A> Base<BR>
<A
 HREF="directive-dict.html#Module"
 REL="Help"
><STRONG>Module:</STRONG></A> mod_access<BR>
<A
 HREF="directive-dict.html#Compatibility"
 REL="Help"
><STRONG>Compatibility:</STRONG></A> Apache 1.2 and above
</P>
<P>
The <CODE>Deny from env</CODE> directive controls access to a directory by the
existence (or non-existence) of an environment variable.
</P>
<P>
Example:
</P>
<BLOCKQUOTE><PRE>
SetEnvIf User-Agent ^BadRobot/0.9 go_away
&lt;Directory /docroot&gt;
    Order Allow,Deny
    Allow from all
    Deny from env=go_away
&lt;/Directory&gt;
</PRE></BLOCKQUOTE>
In this case browsers with the user-agent string <TT>BadRobot/0.9</TT> will
be denied access, and all others will be allowed.

<P>
See also <A HREF="#allowfromenv">Allow from env=</A>, <A
HREF="#order">Order</A> and <A
HREF="mod_setenvif.html#SetEnvIf">SetEnvIf</A>.
</P>
<HR>

<H2><A NAME="order">Order directive</A></H2>
<P>
<!--%plaintext &lt;?INDEX {\tt Order} directive&gt; -->
<A
 HREF="directive-dict.html#Syntax"
 REL="Help"
><STRONG>Syntax:</STRONG></A> Order <EM>ordering</EM><BR>
<A
 HREF="directive-dict.html#Default"
 REL="Help"
><STRONG>Default:</STRONG></A> <CODE>Order Deny,Allow</CODE><BR>
<A
 HREF="directive-dict.html#Context"
 REL="Help"
><STRONG>Context:</STRONG></A> directory, .htaccess<BR>
<A
 HREF="directive-dict.html#Override"
 REL="Help"
><STRONG>Override:</STRONG></A> Limit<BR>
<A
 HREF="directive-dict.html#Status"
 REL="Help"
><STRONG>Status:</STRONG></A> Base<BR>
<A
 HREF="directive-dict.html#Module"
 REL="Help"
><STRONG>Module:</STRONG></A> mod_access
</P>
<P>
The <CODE>Order</CODE> directive controls the order in which 
<A HREF="#allow">Allow</A> and <A HREF="#deny">Deny</A> directives are
evaluated. <EM>Ordering</EM> is one
of
</P>
<DL>
<DT>Deny,Allow
<DD>the <CODE>Deny</CODE> directives are evaluated before the <CODE>Allow</CODE>
directives.  (The initial state is OK.)
<DT>Allow,Deny
<DD>the <CODE>Allow</CODE> directives are evaluated before the <CODE>Deny</CODE>
directives.  (The initial state is FORBIDDEN.)
<DT>Mutual-failure
<DD>Only those hosts which appear on the <CODE>Allow</CODE> list and do not
appear on the <CODE>Deny</CODE> list are granted access.  (The initial state is
irrelevant.)  This ordering has the same effect as <code>Order Allow,Deny</code>
and is deprecated in favor of that configuration.
</DL>
<P>
Keywords may only be separated by a comma; no whitespace is allowed between
them.
<STRONG>Note that in all cases every <CODE>Allow</CODE> and <CODE>Deny</CODE>
statement is evaluated, there is no &quot;short-circuiting&quot;.</STRONG>
</P>
<P>
Example:
</P>
<BLOCKQUOTE><CODE>
    Order Deny,Allow<BR>
    Deny from all<BR>
    Allow from .ncsa.uiuc.edu<BR>
</CODE></BLOCKQUOTE>
<P>
Hosts in the ncsa.uiuc.edu domain are allowed access; all other hosts are
denied access.
</P>

<P>See also: <A HREF="#deny">Deny</A> and <A HREF="#allow">Allow</A>.
<HR>

<H3 ALIGN="CENTER">
 Apache HTTP Server Version 1.3
</H3>

<A HREF="./"><IMG SRC="../images/index.gif" ALT="Index"></A>
<A HREF="../"><IMG SRC="../images/home.gif" ALT="Home"></A>

</BODY>
</HTML>