First create the following configuration file under the conf directory of nginx and name it blocksip.conf:
deny 95.105.25.181;
save it.
Add to the nginx configuration file nginx.conf: include blocksip.conf;
restart the nginx service: /usr/local/nginx/sbin/nginx -s reload will take effect.
There are many formats of blocksip.conf:, you can configure only allowed IP access or IP segment access:
deny IP;
allow IP;
# block all ips
deny all;
# allow all ips
allow all;
allow 1.1.1.1;
allow 1.1.1.2;
deny all;
deny 95.105.25.181;
save it.
Add to the nginx configuration file nginx.conf: include blocksip.conf;
restart the nginx service: /usr/local/nginx/sbin/nginx -s reload will take effect.
There are many formats of blocksip.conf:, you can configure only allowed IP access or IP segment access:
deny IP;
allow IP;
# block all ips
deny all;
# allow all ips
allow all;
The network segment is written like this: 192.168.1.0/24.
deny 192.168.1.11;
deny 192.168.1.123;
deny 10.0.1.0/24;
If you want to implement such an application, reject all but a few IPs,
That requires you to write this in ip.balcklist
allow 1.1.1.1;
allow 1.1.1.2;
deny all;
How to block IP for a separate website:
In server "{}", adding deny IP address in the braces restricts access to a certain IP address; allow IP address only allows access to a certain IP address;
#屏蔽单个IP的命令是
deny 123.45.6.7
#封整个段即从123.0.0.1到123.255.255.254的命令
deny 123.0.0.0/8
#封IP段即从123.45.0.1到123.45.255.254的命令
deny 124.45.0.0/16
#封IP段即从123.45.6.1到123.45.6.254的命令是
deny 123.45.6.0/24