feat(firewall): Ban AI crawlers

This commit is contained in:
Tom Hubrecht 2025-01-06 00:11:56 +01:00
parent c4108a62ab
commit e0cfd1ceb0
Signed by: thubrecht
SSH key fingerprint: SHA256:r+nK/SIcWlJ0zFZJGHtlAoRwq1Rm+WcKAm5ADYMoQPc

View file

@ -25,6 +25,43 @@ let
};
available = {
ai-crawlers = {
cmd = [
"tail"
"-n0"
"-f"
"/var/log/nginx/access.log"
];
filters.bots = {
regex = builtins.map (name: ''^<ip>.*"[^"]*${name}[^"]*"$'') [
"AI2Bot"
"Amazonbot"
"Applebot"
"Applebot-Extended"
"Bytespider"
"CCBot"
"ChatGPT-User"
"ClaudeBot"
"Diffbot"
"DuckAssistBot"
"FacebookBot"
"GPTBot"
"Google-Extended"
"Kangaroo Bot"
"Meta-ExternalAgent"
"Meta-ExternalFetcher"
"OAI-SearchBot"
"PerplexityBot"
"Timpibot"
"Webzio-Extended"
"YouBot"
"omgili"
];
actions = ban "720h";
};
};
ssh = {
cmd = journalctl "sshd";
@ -46,5 +83,8 @@ let
in
builtins.mapAttrs (_: builtins.foldl' (a: s: a // { ${s} = available.${s}; }) { }) {
default = [ "ssh" ];
default = [
"ai-crawlers"
"ssh"
];
}