summaryrefslogtreecommitdiff
path: root/docs/manual/mod/mod_access.html
blob: 82cd71c69f6d450bf61204dc7ec2ee9dabd7c1dd (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
<!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"
>
<!--#include virtual="header.html" -->

<H1 ALIGN="CENTER">Module mod_access</H1>
<P>
This module is contained in the <CODE>mod_access.c</CODE> file, and
is compiled in by default. It provides access control based on client
hostname or IP address.
</P>

<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>
<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="#deny">deny</A>, <A HREF="#order">order</A>, and
<A HREF="mod_browser.html#browsermatch">BrowserMatch</A>.
</P>

<P>
<A NAME="allowfromenv"><STRONG>Syntax:</STRONG> allow from
 env=<EM>variablename</EM></A><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 allow from env directive controls access to a directory by the
existence (or non-existence) of an environment variable.
</P>
<P>
Example:
</P>
<BLOCKQUOTE><PRE>
BrowserMatch ^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>
and <A HREF="#order">order</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 deny 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="#allow">allow</A> and <A HREF="#order">order</A>.
</P>

<P>
<A NAME="denyfromenv"><STRONG>Syntax:</STRONG> deny from
 env=<EM>variablename</EM></A><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 deny from env directive controls access to a directory by the
existence (or non-existence) of an environment variable.
</P>
<P>
Example:
</P>
<BLOCKQUOTE><PRE>
BrowserMatch ^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>
and <A HREF="#order">order</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 order 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 deny directives are evaluated before the allow directives.  (The
initial state is OK.)
<DT>allow,deny
<DD>the allow directives are evaluated before the deny directives.  (The
initial state is FORBIDDEN.)
<DT>mutual-failure
<DD>Only those hosts which appear on the allow list and do not appear
on the deny list are granted access.  (The initial state is irrelevant.)
</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>
<!--#include virtual="footer.html" -->
</BODY>
</HTML>