Apache HTTP Server Version 2.4
Available Languages: ja
Description: | Group authorizations based on host (name or IP address) |
---|---|
Status: | Extension |
Module Identifier: | access_compat_module |
Source File: | mod_access_compat.c |
Compatibility: | Available in Apache HTTP Server 2.3 as a compatibility module with previous versions of Apache httpd 2.x. The directives provided by this module have been deprecated by the new authz refactoring. Please see mod_authz_host |
The directives provided by Deny
directives interact with each other.
Both host-based access restrictions and -based authentication may be implemented simultaneously. In that case, the Satisfy
directive is used to determine how the two sets of restrictions interact.
The directives provided by upgrading guide for more information.
In general, access restriction directives apply to all access methods (GET
, PUT
, POST
, 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 <Limit>
section.
When any directive provided by this module is used in a new configuration section, no directives provided by this module are inherited from previous configuration sections.
Description: | Controls which hosts can access an area of the server |
---|---|
Syntax: | Allow from all|host|env=[!]env-variable [host|env=[!]env-variable] ... |
Context: | directory, .htaccess |
Override: | Limit |
Status: | Extension |
Module: | mod_access_compat |
The Allow
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.
The first argument to this directive is always from
. The subsequent arguments can take three different forms. If Allow from all
is specified, then all hosts are allowed access, subject to the configuration of the Order
directives as discussed below. To allow only particular hosts or groups of hosts to access the server, the host can be specified in any of the following formats:
Allow from example.org Allow from .net example.edu
Hosts whose names match, or end in, this string are allowed access. Only complete components are matched, so the above example will match foo.example.org
but it will not match fooexample.org
. This configuration will cause Apache httpd to perform a double DNS lookup on the client IP address, regardless of the setting of the HostnameLookups
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.
Allow from 10.1.2.3 Allow from 192.168.1.104 192.168.1.205
An IP address of a host allowed access
Allow from 10.1 Allow from 10 172.20 192.168.2
The first 1 to 3 bytes of an IP address, for subnet restriction.
Allow from 10.1.0.0/255.255.0.0
A network a.b.c.d, and a netmask w.x.y.z. For more fine-grained subnet restriction.
Allow from 10.1.0.0/16
Similar to the previous case, except the netmask consists of nnn high-order 1 bits.
Note that the last three examples above match exactly the same set of hosts.
IPv6 addresses and IPv6 subnets can be specified as shown below:
Allow from 2001:db8::a00:20ff:fea7:ccea Allow from 2001:db8::a00:20ff:fea7:ccea/10
The third format of the arguments to the Allow
directive allows access to the server to be controlled based on the existence of an mod_setenvif. Therefore, this directive can be used to allow access based on such factors as the clients -Agent
(browser type), Referer
, or other HTTP request header fields.
SetEnvIf -Agent ^KnockKnock/2\.0 let_me_in <Directory "/docroot"> Order Deny,Allow Deny from all Allow from env=let_me_in </Directory>
In this case, browsers with a -agent string beginning with KnockKnock/2.0
will be allowed access, and all others will be denied.
When any directive provided by this module is used in a new configuration section, no directives provided by this module are inherited from previous configuration sections.
Description: | Controls which hosts are denied access to the server |
---|---|
Syntax: | Deny from all|host|env=[!]env-variable [host|env=[!]env-variable] ... |
Context: | directory, .htaccess |
Override: | Limit |
Status: | Extension |
Module: | mod_access_compat |
This directive allows access to the server to be restricted based on hostname, IP address, or environment variables. The arguments for the Deny
directive are identical to the arguments for the Allow
directive.
Description: | Controls the default access state and the order in which Allow and Deny are evaluated. |
---|---|
Syntax: | Order ordering |
Default: | Order Deny,Allow |
Context: | directory, .htaccess |
Override: | Limit |
Status: | Extension |
Module: | mod_access_compat |
The Order
directive, along with the Allow
). The third applies to all requests which do not match either of the first two.
Note that all Deny
lines are considered as another, and the default state is considered by itself.
Ordering is one of:
Allow,Deny
Deny
directive are denied by default.
Deny,Allow
Deny
directives are permitted.
Mutual-failure
Order Allow,Deny
and is deprecated in its favor.
Keywords may only be separated by a comma; no whitespace is allowed between them.
Match | Allow,Deny result | Deny,Allow result |
---|---|---|
Match Allow only | Request allowed | Request allowed |
Match Deny only | Request denied | Request denied |
No match | Default to second directive: Denied | Default to second directive: Allowed |
Match both Allow & Deny | Final match controls: Denied | Final match controls: Allowed |
In the following example, all hosts in the example.org domain are allowed access; all other hosts are denied access.
Order Deny,Allow Deny from all Allow from example.org
In the next example, all hosts in the example.org domain are allowed access, except for the hosts which are in the foo.example.org subdomain, who are denied access. All hosts not in the example.org domain are denied access because the default state is to Deny
access to the server.
Order Allow,Deny Allow from example.org Deny from foo.example.org
On the other hand, if the Order
in the last example is changed to Deny,Allow
, all hosts will be allowed access. This happens because, regardless of the actual ordering of the directives in the configuration file, the Allow from example.org
will be evaluated last and will override the Deny from foo.example.org
. All hosts not in the example.org
domain will also be allowed access because the default state is Allow
.
The presence of an Order
directive can affect access to a part of the server even in the absence of accompanying Deny
directives because of its effect on the default access state. For example,
<Directory "/www"> Order Allow,Deny </Directory>
will Deny all access to the /www
directory because the default access state is set to Deny
.
The Order
directive controls the order of access directive processing only within each phase of the server's configuration processing. This implies, for example, that an How Directory, Location and Files sections work.
When any directive provided by this module is used in a new configuration section, no directives provided by this module are inherited from previous configuration sections.
Description: | Interaction between host-level access control and authentication |
---|---|
Syntax: | Satisfy Any|All |
Default: | Satisfy All |
Context: | directory, .htaccess |
Override: | AuthConfig |
Status: | Extension |
Module: | mod_access_compat |
Compatibility: | Influenced by <LimitExcept> in version 2.0.51 and later |
Access policy if both Require
used. The parameter can be either All
or Any
. This directive is only useful if access to a particular area is being restricted by both name/ and client host address. In this case the default behavior (All
) is to require that the client es the address access restriction and enters a valid name and . With the Any
option the client will be granted access if they either the host restriction or enter a valid name and . This can be used to restrict an area, but to let clients from particular addresses in without prompting for a .
For example, if you wanted to let people on your network have unrestricted access to a portion of your website, but require that people outside of your network provide a , you could use a configuration similar to the following:
Require valid- Allow from 192.168.1 Satisfy Any
Another frequent use of the Satisfy
directive is to relax access restrictions for a subdirectory:
<Directory "/var/www/private"> Require valid- </Directory> <Directory "/var/www/private/public"> Allow from all Satisfy Any </Directory>
In the above example, authentication will be required for the /var/www/private
directory, but will not be required for the /var/www/private/public
directory.
Since version 2.0.51 Satisfy
directives can be restricted to particular methods by <LimitExcept>
sections.
When any directive provided by this module is used in a new configuration section, no directives provided by this module are inherited from previous configuration sections.
Available Languages: ja