github.com/krum110487/go-htaccess@v0.0.0-20240316004156-60641c8e7598/tests/data/apache_2_2_34/manual/mod/mod_authz_host.html.en (about) 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 <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type" /> 5 <!-- 6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 7 This file is generated from xml source: DO NOT EDIT 8 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 9 --> 10 <title>mod_authz_host - Apache HTTP Server Version 2.2</title> 11 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> 12 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> 13 <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> 14 <script src="../style/scripts/prettify.min.js" type="text/javascript"> 15 </script> 16 17 <link href="../images/favicon.ico" rel="shortcut icon" /><link href="http://httpd.apache.org/docs/current/mod/mod_authz_host.html" rel="canonical" /></head> 18 <body> 19 <div id="page-header"> 20 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p> 21 <p class="apache">Apache HTTP Server Version 2.2</p> 22 <img alt="" src="../images/feather.gif" /></div> 23 <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> 24 <div id="path"> 25 <a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.2</a> > <a href="./">Modules</a></div> 26 <div id="page-content"> 27 <div class="retired"><h4>Please note</h4> 28 <p> This document refers to a legacy release (<strong>2.2</strong>) of Apache httpd. The active release (<strong>2.4</strong>) is documented <a href="http://httpd.apache.org/docs/current">here</a>. If you have not already upgraded, please follow <a href="http://httpd.apache.org/docs/current/upgrading.html">this link</a> for more information.</p> 29 <p>You may follow <a href="http://httpd.apache.org/docs/current/mod/mod_authz_host.html">this link</a> to go to the current version of this document.</p></div><div id="preamble"><h1>Apache Module mod_authz_host</h1> 30 <div class="toplang"> 31 <p><span>Available Languages: </span><a href="../en/mod/mod_authz_host.html" title="English"> en </a> | 32 <a href="../fr/mod/mod_authz_host.html" hreflang="fr" rel="alternate" title="Français"> fr </a> | 33 <a href="../ja/mod/mod_authz_host.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> | 34 <a href="../ko/mod/mod_authz_host.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p> 35 </div> 36 <table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Group authorizations based on host (name or IP 37 address)</td></tr> 38 <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Base</td></tr> 39 <tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>authz_host_module</td></tr> 40 <tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>mod_authz_host.c</td></tr> 41 <tr><th><a href="module-dict.html#Compatibility">Compatibility:</a></th><td>Available in Apache 2.1 and later</td></tr></table> 42 <h3>Summary</h3> 43 44 <p>The directives provided by <code class="module"><a href="../mod/mod_authz_host.html">mod_authz_host</a></code> are 45 used in <code class="directive"><a href="../mod/core.html#directory"><Directory></a></code>, 46 <code class="directive"><a href="../mod/core.html#files"><Files></a></code>, and 47 <code class="directive"><a href="../mod/core.html#location"><Location></a></code> sections 48 as well as <code><a href="core.html#accessfilename">.htaccess</a> 49 </code> files to control access to particular parts of the server. 50 Access can be controlled based on the client hostname, IP address, or 51 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 52 specify which clients are or are not allowed access to the server, 53 while the <code class="directive"><a href="#order">Order</a></code> 54 directive sets the default access state, and configures how the 55 <code class="directive"><a href="#allow">Allow</a></code> and <code class="directive"><a href="#deny">Deny</a></code> directives interact with each 56 other.</p> 57 58 <p>Both host-based access restrictions and password-based 59 authentication may be implemented simultaneously. In that case, 60 the <code class="directive"><a href="../mod/core.html#satisfy">Satisfy</a></code> directive is used 61 to determine how the two sets of restrictions interact.</p> 62 63 <p>In general, access restriction directives apply to all 64 access methods (<code>GET</code>, <code>PUT</code>, 65 <code>POST</code>, etc). This is the desired behavior in most 66 cases. However, it is possible to restrict some methods, while 67 leaving other methods unrestricted, by enclosing the directives 68 in a <code class="directive"><a href="../mod/core.html#limit"><Limit></a></code> section.</p> 69 </div> 70 <div id="quickview"><h3 class="directives">Directives</h3> 71 <ul id="toc"> 72 <li><img alt="" src="../images/down.gif" /> <a href="#allow">Allow</a></li> 73 <li><img alt="" src="../images/down.gif" /> <a href="#deny">Deny</a></li> 74 <li><img alt="" src="../images/down.gif" /> <a href="#order">Order</a></li> 75 </ul> 76 <h3>See also</h3> 77 <ul class="seealso"> 78 <li><code class="directive"><a href="../mod/core.html#satisfy">Satisfy</a></code></li> 79 <li><code class="directive"><a href="../mod/core.html#require">Require</a></code></li> 80 </ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div> 81 82 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> 83 <div class="directive-section"><h2><a name="Allow" id="Allow">Allow</a> <a name="allow" id="allow">Directive</a></h2> 84 <table class="directive"> 85 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Controls which hosts can access an area of the 86 server</td></tr> 87 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code> Allow from all|<var>host</var>|env=[!]<var>env-variable</var> 88 [<var>host</var>|env=[!]<var>env-variable</var>] ...</code></td></tr> 89 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory, .htaccess</td></tr> 90 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>Limit</td></tr> 91 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr> 92 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_authz_host</td></tr> 93 <tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Support for negating env=<var>env-variable</var> was added in 2.2.10</td></tr> 94 </table> 95 <p>The <code class="directive">Allow</code> directive affects which hosts can 96 access an area of the server. Access can be controlled by 97 hostname, IP address, IP address range, or by other 98 characteristics of the client request captured in environment 99 variables.</p> 100 101 <p>The first argument to this directive is always 102 <code>from</code>. The subsequent arguments can take three 103 different forms. If <code>Allow from all</code> is specified, then 104 all hosts are allowed access, subject to the configuration of the 105 <code class="directive"><a href="#deny">Deny</a></code> and <code class="directive"><a href="#order">Order</a></code> directives as discussed 106 below. To allow only particular hosts or groups of hosts to access 107 the server, the <em>host</em> can be specified in any of the 108 following formats:</p> 109 110 <dl> 111 <dt>A (partial) domain-name</dt> 112 113 <dd> 114 <div class="example"><h3>Example:</h3><p><code> 115 Allow from apache.org<br /> 116 Allow from .net example.edu 117 </code></p></div> 118 <p>Hosts whose names match, or end in, this string are allowed 119 access. Only complete components are matched, so the above 120 example will match <code>foo.apache.org</code> but it will not 121 match <code>fooapache.org</code>. This configuration will cause 122 Apache to perform a double reverse DNS lookup on the client IP 123 address, regardless of the setting of the <code class="directive"><a href="../mod/core.html#hostnamelookups">HostnameLookups</a></code> directive. It will do 124 a reverse DNS lookup on the IP address to find the associated 125 hostname, and then do a forward lookup on the hostname to assure 126 that it matches the original IP address. Only if the forward 127 and reverse DNS are consistent and the hostname matches will 128 access be allowed.</p></dd> 129 130 <dt>A full IP address</dt> 131 132 <dd> 133 <div class="example"><h3>Example:</h3><p><code> 134 Allow from 10.1.2.3<br /> 135 Allow from 192.168.1.104 192.168.1.205 136 </code></p></div> 137 <p>An IP address of a host allowed access</p></dd> 138 139 <dt>A partial IP address</dt> 140 141 <dd> 142 <div class="example"><h3>Example:</h3><p><code> 143 Allow from 10.1<br /> 144 Allow from 10 172.20 192.168.2 145 </code></p></div> 146 <p>The first 1 to 3 bytes of an IP address, for subnet 147 restriction.</p></dd> 148 149 <dt>A network/netmask pair</dt> 150 151 <dd> 152 <div class="example"><h3>Example:</h3><p><code> 153 Allow from 10.1.0.0/255.255.0.0 154 </code></p></div> 155 <p>A network a.b.c.d, and a netmask w.x.y.z. For more 156 fine-grained subnet restriction.</p></dd> 157 158 <dt>A network/nnn CIDR specification</dt> 159 160 <dd> 161 <div class="example"><h3>Example:</h3><p><code> 162 Allow from 10.1.0.0/16 163 </code></p></div> 164 <p>Similar to the previous case, except the netmask consists of 165 nnn high-order 1 bits.</p></dd> 166 </dl> 167 168 <p>Note that the last three examples above match exactly the 169 same set of hosts.</p> 170 171 <p>IPv6 addresses and IPv6 subnets can be specified as shown 172 below:</p> 173 174 <div class="example"><p><code> 175 Allow from 2001:db8::a00:20ff:fea7:ccea<br /> 176 Allow from 2001:db8::a00:20ff:fea7:ccea/10 177 </code></p></div> 178 179 <p>The third format of the arguments to the 180 <code class="directive">Allow</code> directive allows access to the server 181 to be controlled based on the existence of an <a href="../env.html">environment variable</a>. When <code>Allow from 182 env=<var>env-variable</var></code> is specified, then the request is 183 allowed access if the environment variable <var>env-variable</var> 184 exists. When <code>Allow from env=!<var>env-variable</var></code> is 185 specified, then the request is allowed access if the environment 186 variable <var>env-variable</var> doesn't exist. 187 The server provides the ability to set environment 188 variables in a flexible way based on characteristics of the client 189 request using the directives provided by 190 <code class="module"><a href="../mod/mod_setenvif.html">mod_setenvif</a></code>. Therefore, this directive can be 191 used to allow access based on such factors as the clients 192 <code>User-Agent</code> (browser type), <code>Referer</code>, or 193 other HTTP request header fields.</p> 194 195 <div class="example"><h3>Example:</h3><p><code> 196 SetEnvIf User-Agent ^KnockKnock/2\.0 let_me_in<br /> 197 <Directory /docroot><br /> 198 <span class="indent"> 199 Order Deny,Allow<br /> 200 Deny from all<br /> 201 Allow from env=let_me_in<br /> 202 </span> 203 </Directory> 204 </code></p></div> 205 206 <p>In this case, browsers with a user-agent string beginning 207 with <code>KnockKnock/2.0</code> will be allowed access, and all 208 others will be denied.</p> 209 210 </div> 211 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> 212 <div class="directive-section"><h2><a name="Deny" id="Deny">Deny</a> <a name="deny" id="deny">Directive</a></h2> 213 <table class="directive"> 214 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Controls which hosts are denied access to the 215 server</td></tr> 216 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code> Deny from all|<var>host</var>|env=[!]<var>env-variable</var> 217 [<var>host</var>|env=[!]<var>env-variable</var>] ...</code></td></tr> 218 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory, .htaccess</td></tr> 219 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>Limit</td></tr> 220 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr> 221 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_authz_host</td></tr> 222 </table> 223 <p>This directive allows access to the server to be restricted 224 based on hostname, IP address, or environment variables. The 225 arguments for the <code class="directive">Deny</code> directive are 226 identical to the arguments for the <code class="directive"><a href="#allow">Allow</a></code> directive.</p> 227 228 </div> 229 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> 230 <div class="directive-section"><h2><a name="Order" id="Order">Order</a> <a name="order" id="order">Directive</a></h2> 231 <table class="directive"> 232 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Controls the default access state and the order in which 233 <code class="directive">Allow</code> and <code class="directive">Deny</code> are 234 evaluated.</td></tr> 235 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code> Order <var>ordering</var></code></td></tr> 236 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>Order Deny,Allow</code></td></tr> 237 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory, .htaccess</td></tr> 238 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>Limit</td></tr> 239 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr> 240 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_authz_host</td></tr> 241 </table> 242 243 <p>The <code class="directive">Order</code> directive, along with the 244 <code class="directive"><a href="#allow">Allow</a></code> and <code class="directive"><a href="#deny">Deny</a></code> directives, controls a 245 three-pass access control system. The first pass processes either 246 all <code class="directive"><a href="#allow">Allow</a></code> or all 247 <code class="directive"><a href="#deny">Deny</a></code> directives, as 248 specified by the <code class="directive">Order</code> directive. The second 249 pass parses the rest of the directives (<code class="directive"><a href="#deny">Deny</a></code> or <code class="directive"><a href="#allow">Allow</a></code>). The third pass applies 250 to all requests which do not match either of the first two.</p> 251 252 <p>Note that all <code class="directive"><a href="#allow">Allow</a></code> and <code class="directive"><a href="#deny">Deny</a></code> directives are processed, 253 unlike a typical firewall, where only the first match is used. The 254 last match is effective (also unlike a typical firewall). 255 Additionally, the order in which lines appear in the configuration 256 files is not significant -- all <code class="directive"><a href="#allow">Allow</a></code> lines are processed as one 257 group, all <code class="directive"><a href="#deny">Deny</a></code> lines 258 are considered as another, and the default state is considered by 259 itself.</p> 260 261 <p><em>Ordering</em> is one of:</p> 262 263 <dl> 264 <dt><code>Allow,Deny</code></dt> 265 266 <dd>First, all <code class="directive"><a href="#allow">Allow</a></code> directives are 267 evaluated; at least one must match, or the request is rejected. 268 Next, all <code class="directive"><a href="#deny">Deny</a></code> 269 directives are evaluated. If any matches, the request is rejected. 270 Last, any requests which do not match an <code class="directive"><a href="#allow">Allow</a></code> or a <code class="directive"><a href="#deny">Deny</a></code> directive are denied by 271 default.</dd> 272 273 <dt><code>Deny,Allow</code></dt> 274 275 <dd>First, all <code class="directive"><a href="#deny">Deny</a></code> 276 directives are evaluated; if any match, the request is denied 277 <strong>unless</strong> it also matches an <code class="directive"><a href="#allow">Allow</a></code> directive. Any requests 278 which do not match any <code class="directive"><a href="#allow">Allow</a></code> or <code class="directive"><a href="#deny">Deny</a></code> directives are 279 permitted.</dd> 280 281 <dt><code>Mutual-failure</code></dt> 282 283 <dd>This order has the same effect as <code>Order 284 Allow,Deny</code> and is deprecated in its favor.</dd> 285 </dl> 286 287 <p>Keywords may only be separated by a comma; <em>no whitespace</em> 288 is allowed between them.</p> 289 290 <table class="bordered"> 291 <tr> 292 <th>Match</th> 293 <th>Allow,Deny result</th> 294 <th>Deny,Allow result</th> 295 </tr><tr> 296 <th>Match Allow only</th> 297 <td>Request allowed</td> 298 <td>Request allowed</td> 299 </tr><tr> 300 <th>Match Deny only</th> 301 <td>Request denied</td> 302 <td>Request denied</td> 303 </tr><tr> 304 <th>No match</th> 305 <td>Default to second directive: Denied</td> 306 <td>Default to second directive: Allowed</td> 307 </tr><tr> 308 <th>Match both Allow & Deny</th> 309 <td>Final match controls: Denied</td> 310 <td>Final match controls: Allowed</td> 311 </tr> 312 </table> 313 314 <p>In the following example, all hosts in the apache.org domain 315 are allowed access; all other hosts are denied access.</p> 316 317 <div class="example"><p><code> 318 Order Deny,Allow<br /> 319 Deny from all<br /> 320 Allow from apache.org 321 </code></p></div> 322 323 <p>In the next example, all hosts in the apache.org domain are 324 allowed access, except for the hosts which are in the foo.apache.org 325 subdomain, who are denied access. All hosts not in the apache.org 326 domain are denied access because the default state is to <code class="directive"><a href="#deny">Deny</a></code> access to the server.</p> 327 328 <div class="example"><p><code> 329 Order Allow,Deny<br /> 330 Allow from apache.org<br /> 331 Deny from foo.apache.org 332 </code></p></div> 333 334 <p>On the other hand, if the <code class="directive">Order</code> in the 335 last example is changed to <code>Deny,Allow</code>, all hosts will 336 be allowed access. This happens because, regardless of the actual 337 ordering of the directives in the configuration file, the 338 <code>Allow from apache.org</code> will be evaluated last and will 339 override the <code>Deny from foo.apache.org</code>. All hosts not in 340 the <code>apache.org</code> domain will also be allowed access 341 because the default state is <code class="directive"><a href="#allow">Allow</a></code>.</p> 342 343 <p>The presence of an <code class="directive">Order</code> directive can 344 affect access to a part of the server even in the absence of 345 accompanying <code class="directive"><a href="#allow">Allow</a></code> 346 and <code class="directive"><a href="#deny">Deny</a></code> directives 347 because of its effect on the default access state. For example,</p> 348 349 <div class="example"><p><code> 350 <Directory /www><br /> 351 <span class="indent"> 352 Order Allow,Deny<br /> 353 </span> 354 </Directory> 355 </code></p></div> 356 357 <p>will Deny all access to the <code>/www</code> directory 358 because the default access state is set to 359 <code class="directive"><a href="#deny">Deny</a></code>.</p> 360 361 <p>The <code class="directive">Order</code> directive controls the order of 362 access directive processing only within each phase of the server's 363 configuration processing. This implies, for example, that an 364 <code class="directive"><a href="#allow">Allow</a></code> or <code class="directive"><a href="#deny">Deny</a></code> directive occurring in a 365 <code class="directive"><a href="../mod/core.html#location"><Location></a></code> section 366 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 367 <code class="directive"><a href="../mod/core.html#directory"><Directory></a></code> 368 section or <code>.htaccess</code> file, regardless of the setting of 369 the <code class="directive">Order</code> directive. For details on the 370 merging of configuration sections, see the documentation on <a href="../sections.html">How Directory, Location and Files sections 371 work</a>.</p> 372 373 </div> 374 </div> 375 <div class="bottomlang"> 376 <p><span>Available Languages: </span><a href="../en/mod/mod_authz_host.html" title="English"> en </a> | 377 <a href="../fr/mod/mod_authz_host.html" hreflang="fr" rel="alternate" title="Français"> fr </a> | 378 <a href="../ja/mod/mod_authz_host.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> | 379 <a href="../ko/mod/mod_authz_host.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p> 380 </div><div class="top"><a href="#page-header"><img src="../images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div> 381 <script type="text/javascript"><!--//--><![CDATA[//><!-- 382 var comments_shortname = 'httpd'; 383 var comments_identifier = 'http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html'; 384 (function(w, d) { 385 if (w.location.hostname.toLowerCase() == "httpd.apache.org") { 386 d.write('<div id="comments_thread"><\/div>'); 387 var s = d.createElement('script'); 388 s.type = 'text/javascript'; 389 s.async = true; 390 s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; 391 (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); 392 } 393 else { 394 d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); 395 } 396 })(window, document); 397 //--><!]]></script></div><div id="footer"> 398 <p class="apache">Copyright 2017 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> 399 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- 400 if (typeof(prettyPrint) !== 'undefined') { 401 prettyPrint(); 402 } 403 //--><!]]></script> 404 </body></html>