How to block IP range with nginx
In my server, I use nginx as web server. This server receives many visits from bad bots.
I know how to block specific ip, editing /etc/nginx/nginx.conf file and within the server block, add this line (example): deny 74.208.136.135;
But I want to block all access from 74.208.***.***
Is this possible with nginx?
The Answer as already been told in the comments
deny accepts as stated in NGINX Manual:
- hostname
- IP
- CIDR
- Unix-Socket
- All
Meaning:
deny my.blocked.host
deny 127.0.0.1
deny 127.0.0.1/8
deny unix:/path/to/socket
deny all
The answer to your Request, which is used to Block a Class A Network which is the same as Netmask 255.255.0.0 or in CIDR /16
the Answer to your Question
deny 75.208.0.0/16;