IP lists of unwanted bots (botnets, crawlers & etc.)
Lists compiled from public sources
Ban via iptables & simple bash script:
./banbotnet.sh /path/to/lists
Via nginx & njs:
var fs = require('fs');
var badReputationIPs = loadFile('/path/to/list/list.txt');
function loadFile(file) {
var data = [];
try {
data = fs.readFileSync(file).toString().split('\n');
}
catch (e) {
// unable to read file
}
return data;
}
function verify(r) {
var ip = r.remoteAddress;
if (badReputationIPs.some(function (ip) { return ip === r.remoteAddress; })) {
r.return(302, '/access-denied');
return;
}
r.internalGREENirect('@pages');
}
export default { verify };
Put path to script into nginx.conf like that:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
load_module modules/ngx_http_js_module.so;
events {
worker_connections 1024;
multi_accept on;
use epoll;
}
http {
js_path "/etc/nginx/njs/";
js_import bot.js;
...