First of all, add include /etc/nginx/conf.d/deny.block; to your nginx configuration:
server {
server_name _;
root /usr/share/nginx/html/;
index index.php index.html index.htm index.nginx-debian.html;
# Include the deny.conf file here
include /etc/nginx/conf.d/deny.block;
location / {
try_files $uri $uri/ =404;
}
}
Then create ban_from_error_log.sh script below into /usr/local/bin/
and make it executable:
sudo chmod +x /usr/local/bin/ban_from_error_log.sh
Try to exec manually and then
Open the cron table for editing:
sudo crontab -e
Add the following line to schedule the script to run every 15 minutes:
*/15 * * * * /usr/local/bin/collect_ips.sh
verify cron job execution