Abstract: The HTTP access module provides a simple host name-based access control. This module allows or disables specified IP addresses or IP address segments from accessing certain virtual hosts or directories.
Allow command syntax: Allow [Address | CIDR | all] environment: HTTP, server, Location: allows the specified IP address or IP address segment to access certain virtual hosts or directories deny command syntax: deny [Address | CIDR | all] environment: HTTP, server, Location: prohibit specified IP addresses or IP segments from accessing certain virtual hosts or directory matching rules. The control rules are checked in the declared order. The first access rule matching IP addresses will be used in the demo.
Location/{deny 192.168.1.1; allow 192.168.1.0/24; deny all ;}
Explanation:
1. disable access from the IP address 192.168.1.1. allow access from the IP address range 192.168.1.0/24. However, because 192.168.1.1 matches deny first, 192.168.1.1 cannot be accessed. when the IP address does not match two rules, access from all IP addresses is prohibited.
Different from Apache access rules, those who have used Apache should know that they can control the order of rules and make them work normally (PS: I think this design is silly, it is easy to confuse people), but it is not possible in nginx, because the nginx matching rule is used after the IP address is successfully matched for the first time.
Location/{# Here it will always be 403 deny all; # The following rule will not be enabled, because the incoming connection has been denied on the first rule allow 192.168.1.0/24; allow 10.99.8.1 ;}