• Abstract
This module provides simple host-based access control.
Ngx_http_access_module This module can examine the client IP in detail and execute the first matching rule sequentially.
The following example:
Location/{
Deny 192.168.1.1;
Allow 192.168.1.0/24;
Allow 10.1.1.0/16;
Deny all;
}
Only 192.168.1.0/24 and 10.1.1.0/16 network segments are allowed in the example above, but 192.168.1.1 is an exception.
If you are implementing many complex rules, it is best to use the GeoIP module module.
• directives
Allow
Syntax: Allow [address | CIDR | ALL]
Default value: No
Using fields: HTTP, server, location, limit_except
directive specifies the IP or network segment that is allowed to be accessed.
Deny
Syntax: Deny [address | CIDR | ALL]
Default value: No
Using fields: HTTP, server, location, limit_except
directive specifies an IP or network segment that is denied access.
• Tips and Tricks
The Httpaccess module can be used in conjunction with the Error_page directive to redirect an unauthenticated access request.
Error_page 403 http://example.com/forbidden.html;
Location/{
Deny 192.168.1.1;
Allow 192.168.1.0/24;
Allow 10.1.1.0/16;
Deny all;
}
HTTP access Control module (HTTP access)