From http://httpd.apache.org/docs/trunk/mod/mod_authz_host.html
Require ip
The ip
provider allows access to the server to be controlled based on the IP address of the remote client. When Require ip ip-address
is specified, then the request is allowed access if the IP address matches.
A full IP address:
Require ip 10.1.2.3 Require ip 192.168.1.104 192.168.1.205
An IP address of a host allowed access
A partial IP address:
Require ip 10.1 Require ip 10 172.20 192.168.2
The first 1 to 3 bytes of an IP address, for subnet restriction.
A network/netmask pair:
Require ip 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.
A network/nnn CIDR specification:
Require ip 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:
Require ip 2001:db8::a00:20ff:fea7:ccea Require ip 2001:db8::a00:20ff:fea7:ccea/10
Note: As the IP addresses are parsed on startup, expressions are not evaluated at request time.
Require host
The host
provider allows access to the server to be controlled based on the host name of the remote client. When Require host host-name
is specified, then the request is allowed access if the host name matches.
A (partial) domain-name
Require host example.org Require host .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 to perform a double reverse 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.
Require local
The local
provider allows access to the server if any of the following conditions is true:
- the client address matches 127.0.0.0/8
- the client address is ::1
- both the client and the server address of the connection are the same
This allows a convenient way to match connections that originate from the local host:
Require local