feat: cleanup and improve Anubis conf

Factorize and unify the Mirror policy
merge-requests/59/head
Pyjacpp 2026-02-15 19:27:24 +01:00
parent f2aeee6fd5
commit 27a426da82
No known key found for this signature in database
GPG Key ID: ED479A5A26930939
1 changed files with 12 additions and 75 deletions

View File

@ -4,83 +4,20 @@ let
formatJSON = pkgs.formats.json { }; formatJSON = pkgs.formats.json { };
formatYAML = pkgs.formats.yaml { }; formatYAML = pkgs.formats.yaml { };
anubisBotsMirror = formatYAML.generate "anubis_bots_mirror.yaml" [
{
name = "whitelist-crans";
action = "ALLOW";
remote_addresses = [
"185.230.79.0/22"
"2a0c:700::/32"
"46.105.102.188/32"
"2001:41d0:2:d5bc::/128"
];
}
{
name = "no-user-agent";
action = "DENY";
expression = "userAgent == \"\"";
}
{
name = "ban-gpt";
action = "DENY";
user_agent_regex = ".*gpt.*";
}
{
name = "ban-bot";
action = "DENY";
user_agent_regex = ".*(b|B)ot.*";
}
{
name = "ban-WebKit";
action = "DENY";
expression = {
all = [
"userAgent.startsWith(\"Mozilla\")"
"userAgent.startsWith(\"AppleWebKit\")"
"userAgent.startsWith(\"Safari\")"
"userAgent.startsWith(\"Chrome\")"
];
};
}
{
name = "ban-Barkrowler";
action = "DENY";
user_agent_regex = ".*Barkrowler.*";
}
];
anubisMirror = formatJSON.generate "anubis_mirror.json" {
bots = [
{
import = "${anubisBotsMirror}";
}
{
name = "allow-repo";
action = "ALLOW";
path_regex = "^...*";
}
{
name = "deny-other";
path_regex = ".*";
action = "ALLOW";
}
];
};
antiBot = formatYAML.generate "antibot.yaml" [ antiBot = formatYAML.generate "antibot.yaml" [
{ {
name = "whitelist-crans"; name = "whitelist-crans";
action = "ALLOW"; action = "ALLOW";
remote_addresses = [ remote_addresses = [
"185.230.79.0/22" "185.230.79.0/22"
"2a0c:700::/32" "2a0c:700::/32"
"46.105.102.188/32" "46.105.102.188/32"
"2001:41d0:2:d5bc::/128" "2001:41d0:2:d5bc::/128"
]; ];
} }
{ {
# On refuse les bots qui font souvent de la merde. # On refuse les bots qui font souvent de la merde.
# https://github.com/TecharoHQ/anubis/blob/main/data/bots/deny-pathological.yaml # https://github.com/TecharoHQ/anubis/blob/main/data/bots/_deny-pathological.yaml
import = "(data)/bots/_deny-pathological.yaml"; import = "(data)/bots/_deny-pathological.yaml";
} }
{ {
@ -101,7 +38,7 @@ let
} }
{ {
# On refuse si userAgent = "" # On refuse si userAgent = ""
# https://github.com/TecharoHQ/anubis/blob/main/data/common/keep-internet-working.yaml # https://github.com/TecharoHQ/anubis/blob/main/data/common/rfc-violations.yaml
import = "(data)/common/rfc-violations.yaml"; import = "(data)/common/rfc-violations.yaml";
} }
{ {
@ -186,7 +123,7 @@ in
proxyWebsockets = true; proxyWebsockets = true;
}; };
"eclat" = { "eclat" = {
anubisConfig = "${anubisMirror}"; anubisConfig = "${anubisMirrors}";
httpOnly = true; httpOnly = true;
target = "172.16.10.104"; target = "172.16.10.104";
}; };
@ -219,7 +156,7 @@ in
target = "172.16.10.104"; target = "172.16.10.104";
}; };
"mirror" = { "mirror" = {
anubisConfig = "${anubisMirror}"; anubisConfig = "${anubisMirrors}";
httpOnly = true; httpOnly = true;
target = "172.16.10.104"; target = "172.16.10.104";
}; };