From 19f40c1c4c476ce293baecd65a31ad3a32e8cf1e Mon Sep 17 00:00:00 2001 From: Pyjacpp Date: Tue, 27 Oct 2026 22:46:16 +0100 Subject: [PATCH 1/4] =?UTF-8?q?anubis=E2=80=AF:=20modularisation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hosts/vm/reverseproxy/reverseproxy.nix | 233 ++++++++----------------- modules/crans/anubis.nix | 112 ++++++++++++ modules/crans/default.nix | 1 + modules/services/reverseproxy.nix | 64 ++----- 4 files changed, 202 insertions(+), 208 deletions(-) create mode 100644 modules/crans/anubis.nix diff --git a/hosts/vm/reverseproxy/reverseproxy.nix b/hosts/vm/reverseproxy/reverseproxy.nix index 3287e90..4fe964d 100644 --- a/hosts/vm/reverseproxy/reverseproxy.nix +++ b/hosts/vm/reverseproxy/reverseproxy.nix @@ -5,162 +5,79 @@ }: let - formatJSON = pkgs.formats.json { }; - formatYAML = pkgs.formats.yaml { }; - inherit (lib.crans) fetchFromCrans; - antiBot = formatYAML.generate "antibot.yaml" [ + anubisChallenge = [ { - 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" - ]; - } - { - # On refuse les bots qui font souvent de la merde. - # https://github.com/TecharoHQ/anubis/blob/main/data/bots/_deny-pathological.yaml - import = "(data)/bots/_deny-pathological.yaml"; - } - { - # allow google-inspection pour indexer les pages - name = "google-inspection-tool"; - action = "ALLOW"; - user_agent_regex = ".*Google-InspectionTool.*"; - } - { - # On autorise les indexers des moteurs de recherche. - # https://github.com/TecharoHQ/anubis/blob/main/data/crawlers/_allow-good.yaml - import = "(data)/crawlers/_allow-good.yaml"; - } - { - # On autorise l'accès à favicon, robots.txt, well-known, ... - # https://github.com/TecharoHQ/anubis/blob/main/data/common/keep-internet-working.yaml - import = "(data)/common/keep-internet-working.yaml"; - } - { - # On refuse si userAgent = "" - # https://github.com/TecharoHQ/anubis/blob/main/data/common/rfc-violations.yaml - import = "(data)/common/rfc-violations.yaml"; - } - { - # On bloque les AI aggressivement (bots/agent, training et user search par IA) - # https://github.com/TecharoHQ/anubis/blob/main/data/meta/ai-block-aggressive.yaml - import = "(data)/meta/ai-block-aggressive.yaml"; + name = "challenge-other"; + path_regex = "^*"; + action = "CHALLENGE"; } ]; - anubisChallenge = formatJSON.generate "anubis_challenge.json" { - "bots" = [ - { - import = "${antiBot}"; - } - { - name = "challenge-other"; - path_regex = "^*"; - action = "CHALLENGE"; - } - ]; - }; + anubisPerso = [ + { + name = "allow-public"; + path_regex = "^/[a-zA-Z0-9_-]*/public/.*"; + action = "ALLOW"; + } + { + name = "allow-phpmyadmin"; + path_regex = "^/phpmyadmin/.*"; + action = "ALLOW"; + } + { + # geneau utilisait ses pages persos avant la mise en place d'Anubis. + # Le déploiement d'Anubis l'a impacté (cf les mails de fin 2025). + # À titre transitoire, il a été décidé en décembre 2025 de faire une + # exception pour lui permettre de continuer son utilisation des pages + # persos en attente d'une meilleure méthode. + name = "allow-geneau"; + path_regex = "^/geneau/.*"; + action = "ALLOW"; + } + { + name = "challenge-other"; + path_regex = "^.*"; + action = "CHALLENGE"; + } + ]; - anubisAllowOther = formatJSON.generate "anubis_allow.json" { - "bots" = [ - { - import = "${antiBot}"; - } - { - name = "allow-other"; - path_regex = "^*"; - action = "ALLOW"; - } - ]; - }; + anubisMirrors = [ + { + name = "deny-other"; + path_regex = ".*cdimage-.*"; + action = "ALLOW"; + } + { + name = "allow-repo"; + path_regex = "^...*"; + action = "ALLOW"; + } + { + name = "deny-other"; + path_regex = ".*"; + action = "CHALLENGE"; + } + ]; - anubisPerso = formatJSON.generate "anubis_perso.json" { - "bots" = [ - { - import = "${antiBot}"; - } - { - name = "allow-public"; - path_regex = "^/[a-zA-Z0-9_-]*/public/.*"; - action = "ALLOW"; - } - { - name = "allow-phpmyadmin"; - path_regex = "^/phpmyadmin/.*"; - action = "ALLOW"; - } - { - # geneau utilisait ses pages persos avant la mise en place d'Anubis. - # Le déploiement d'Anubis l'a impacté (cf les mails de fin 2025). - # À titre transitoire, il a été décidé en décembre 2025 de faire une - # exception pour lui permettre de continuer son utilisation des pages - # persos en attente d'une meilleure méthode. - name = "allow-geneau"; - path_regex = "^/geneau/.*"; - action = "ALLOW"; - } - { - import = "${antiBot}"; - } - { - name = "challenge-other"; - path_regex = "^.*"; - action = "CHALLENGE"; - } - ]; - }; - - anubisMirrors = formatJSON.generate "anubis_mirrors.json" { - "bots" = [ - { - import = "${antiBot}"; - } - { - name = "deny-other"; - path_regex = ".*cdimage-.*"; - action = "ALLOW"; - } - { - name = "allow-repo"; - path_regex = "^...*"; - action = "ALLOW"; - } - { - name = "deny-other"; - path_regex = ".*"; - action = "CHALLENGE"; - } - ]; - }; - - anubisWiki = formatJSON.generate "anubis_wiki.json" { - "bots" = [ - { - import = "${antiBot}"; - } - { - name = "allow-mediawiki-images"; - path_regex = "^/w/images/.*"; - action = "ALLOW"; - } - { - name = "allow-mediawiki-api"; - path_regex = "^/w/api.php.*"; - action = "ALLOW"; - } - { - name = "challenge-other"; - path_regex = ".*"; - action = "CHALLENGE"; - } - ]; - }; + anubisWiki = [ + { + name = "allow-mediawiki-images"; + path_regex = "^/w/images/.*"; + action = "ALLOW"; + } + { + name = "allow-mediawiki-api"; + path_regex = "^/w/api.php.*"; + action = "ALLOW"; + } + { + name = "challenge-other"; + path_regex = ".*"; + action = "CHALLENGE"; + } + ]; installPartySite = pkgs.python3Packages.buildPythonApplication { name = "site-install-party"; @@ -212,12 +129,12 @@ in proxyWebsockets = true; }; "eclat" = { - anubisConfig = "${anubisMirrors}"; + anubisConfig = anubisMirrors; httpOnly = true; proxyPass = "172.16.10.104"; }; "eclats" = { - anubisConfig = "${anubisMirrors}"; + anubisConfig = anubisMirrors; proxyPass = "172.16.10.104"; }; "element".proxyPass = "172.16.10.118"; @@ -239,7 +156,7 @@ in serverAliases = [ "re2o" ]; }; "install-party" = { - anubisConfig = "${anubisChallenge}"; + anubisConfig = anubisChallenge; serveLocalFiles = "${installPartySite}/site"; serverAliases = [ "i-p" @@ -248,20 +165,20 @@ in ]; }; "lists" = { - anubisConfig = "${anubisChallenge}"; + anubisConfig = anubisChallenge; proxyPass = "172.16.10.110"; }; "mediawiki" = { - anubisConfig = "${anubisWiki}"; + anubisConfig = anubisWiki; proxyPass = "172.16.10.144"; serverAliases = [ "mediakiwi" ]; }; "mirrors" = { - anubisConfig = "${anubisMirrors}"; + anubisConfig = anubisMirrors; proxyPass = "172.16.10.104"; }; "mirror" = { - anubisConfig = "${anubisMirrors}"; + anubisConfig = anubisMirrors; httpOnly = true; proxyPass = "172.16.10.104"; }; @@ -278,7 +195,7 @@ in ]; }; "perso" = { - anubisConfig = "${anubisPerso}"; + anubisConfig = anubisPerso; proxyPass = "172.16.10.31"; serverAliases = [ "clubs" ]; }; @@ -302,7 +219,7 @@ in serverAliases = [ "roundcube" ]; }; "wiki" = { - anubisConfig = "${anubisChallenge}"; + anubisConfig = anubisChallenge; proxyPass = "172.16.10.161"; serverAliases = [ "wikipedia" ]; }; @@ -337,5 +254,5 @@ in }; }; }; - + } diff --git a/modules/crans/anubis.nix b/modules/crans/anubis.nix new file mode 100644 index 0000000..9911691 --- /dev/null +++ b/modules/crans/anubis.nix @@ -0,0 +1,112 @@ +{ + config, + lib, + pkgs, + ... +}: +let + formatJSON = pkgs.formats.json { }; + + inherit (lib) + types + mkEnableOption + mkIf + mkOption + ; + + cfg = config.crans.anubis; +in +{ + options.crans.anubis = { + enable = mkEnableOption "Configuration d’Anubis du Crans."; + instances = mkOption { + type = types.attrsOf ( + types.submodule { + options = { + hostname = mkOption { + type = types.str; + example = "wiki.crans.org"; + description = '' + Hostname to redirect to. + ''; + }; + bind = mkOption { + type = types.str; + example = "/run/anubis/anubis-wiki/socket.sock"; + description = '' + Where Anubis should listen + ''; + }; + target = mkOption { + type = types.str; + example = "unix:///run/nginx/socket.sock"; + description = '' + Target that will handle the request. + ''; + }; + bots = mkOption { + type = types.listOf types.attrs; + description = '' + Anubis bot policy. + ''; + }; + }; + } + ); + }; + }; + + config = mkIf cfg.enable { + age.secrets.anubis-secret = mkIf cfg.enable { + file = ../../secrets/reverseproxy/anubis-secret.age; + owner = "anubis"; + }; + + services.anubis = { + defaultOptions.group = "nginx"; + instances = lib.mapAttrs (name: conf: { + enable = true; + policy = { + extraBots = [ + { + 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" + ]; + } + { + # https://github.com/TecharoHQ/anubis/blob/main/data/botPolicies.yaml + import = "(data)/meta/default-config.yaml"; + } + { + # On refuse si userAgent = "" + # https://github.com/TecharoHQ/anubis/blob/main/data/common/rfc-violations.yaml + import = "(data)/common/rfc-violations.yaml"; + } + ] + ++ conf.bots; + # Inclus via l’import de default-config.yaml. + useDefaultBotRules = false; + }; + settings = { + BIND = conf.bind; + BIND_NETWORK = "unix"; + METRIC_BIND = "/run/anubis/anubis-${name}/metrics.sock"; + TARGET = conf.target; + COOKIE_DOMAIN = conf.hostname; + # TODO: db pour mettre en commun les token. + # Transitoirement on les sépare + COOKIE_PREFIX = "anubis-${conf.hostname}"; + REDIRECT_DOMAINS = conf.hostname; + SOCKET_MODE = "0660"; + # Secret partagé entre les instances + ED25519_PRIVATE_KEY_HEX_FILE = config.age.secrets.anubis-secret.path; + }; + }) cfg.instances; + }; + }; +} diff --git a/modules/crans/default.nix b/modules/crans/default.nix index 4f28495..2dab786 100644 --- a/modules/crans/default.nix +++ b/modules/crans/default.nix @@ -14,6 +14,7 @@ in { imports = [ ./age.nix + ./anubis.nix ./grub.nix ./home.nix ./locale.nix diff --git a/modules/services/reverseproxy.nix b/modules/services/reverseproxy.nix index c7e7c7a..6d8e28f 100644 --- a/modules/services/reverseproxy.nix +++ b/modules/services/reverseproxy.nix @@ -72,19 +72,10 @@ in }; anubisConfig = mkOption { - type = types.nullOr types.str; + type = types.nullOr (types.listOf types.attrs); default = null; description = '' - Chemin du fichier de configuration - ''; - example = "/var/www/anubis.conf"; - }; - - anubisOpenGraph = mkOption { - type = types.bool; - default = true; - description = '' - Activer openGraph pour l'indexation et l'embedding + Configuration pour anubis ''; }; @@ -126,13 +117,13 @@ in }; }; - config = { + config = mkIf cfg.enable { systemd.services = lib.mapAttrs (vhostName: vhostConfig: { wantedBy = [ "multi-user.target" ]; }) cfg.virtualHosts; # On fait un certificat commun pour tous les hosts - security.acme.certs."all.crans.all" = mkIf cfg.enable { + security.acme.certs."all.crans.all" = { domain = "*.crans.${mainTld}"; dnsProvider = "rfc2136"; # Contient le serveur à contacter avec le protocole @@ -160,45 +151,18 @@ in }; }; - age.secrets.anubis-secret = mkIf cfg.enable { - file = ../../secrets/reverseproxy/anubis-secret.age; - owner = "anubis"; + # On active Anubis + crans.anubis = { + enable = true; + instances = lib.mapAttrs (vhostName: vhostConfig: { + hostname = mkHostName vhostName mainTld; + bind = "/run/anubis/anubis-${vhostName}/socket.sock"; + target = "unix:/run/nginx/nginx-${vhostName}.sock"; + bots = vhostConfig.anubisConfig; + }) (lib.filterAttrs (_: c: c.anubisConfig != null) cfg.virtualHosts); }; - services = mkIf cfg.enable { - anubis = { - defaultOptions.group = "nginx"; - instances = lib.mapAttrs ( - vhostName: vhostConfig: - let - hostname = mkHostName vhostName mainTld; - in - mkIf (vhostConfig.anubisConfig != null) { - enable = true; - settings = { - BIND = "/run/anubis/anubis-${vhostName}/socket.sock"; - BIND_NETWORK = "unix"; - METRICS_BIND = "/run/anubis/anubis-${vhostName}/anubis-${vhostName}-metrics.sock"; - TARGET = "unix:///run/nginx/nginx-${vhostName}.sock"; - COOKIE_DOMAIN = hostname; - # TODO: db pour mettre en commun les token. - # Transitoirement on les sépare - COOKIE_PREFIX = "anubis-${vhostName}"; - REDIRECT_DOMAINS = hostname; - SOCKET_MODE = "0660"; - # Secret partagé entre les instances - ED25519_PRIVATE_KEY_HEX_FILE = config.age.secrets.anubis-secret.path; - # OpenGraph config - OG_PASSTHROUGH = vhostConfig.anubisOpenGraph; - OG_EXPIRY_TIME = "24h"; - OG_CACHE_CONSIDER_HOST = true; - # Policy config - POLICY_FNAME = vhostConfig.anubisConfig; - }; - } - ) cfg.virtualHosts; - }; - + services = { logrotate.settings = let # https://github.com/NixOS/nixpkgs/blob/nixos-26.05/nixos/modules/services/web-servers/nginx/default.nix From bf059ed261e19d71c3750eb270d8cbc64aaedaf2 Mon Sep 17 00:00:00 2001 From: Pyjacpp Date: Wed, 28 Oct 2026 22:53:19 +0100 Subject: [PATCH 2/4] Anubis subrequest --- modules/crans/anubis.nix | 18 +++--- modules/services/reverseproxy.nix | 92 ++++++++++++++----------------- 2 files changed, 47 insertions(+), 63 deletions(-) diff --git a/modules/crans/anubis.nix b/modules/crans/anubis.nix index 9911691..e14355e 100644 --- a/modules/crans/anubis.nix +++ b/modules/crans/anubis.nix @@ -1,12 +1,9 @@ { config, lib, - pkgs, ... }: let - formatJSON = pkgs.formats.json { }; - inherit (lib) types mkEnableOption @@ -37,13 +34,6 @@ in Where Anubis should listen ''; }; - target = mkOption { - type = types.str; - example = "unix:///run/nginx/socket.sock"; - description = '' - Target that will handle the request. - ''; - }; bots = mkOption { type = types.listOf types.attrs; description = '' @@ -67,6 +57,12 @@ in instances = lib.mapAttrs (name: conf: { enable = true; policy = { + settings = { + statusCodes = { + CHALLENGE = 200; + DENY = 403; + }; + }; extraBots = [ { name = "whitelist-crans"; @@ -96,7 +92,7 @@ in BIND = conf.bind; BIND_NETWORK = "unix"; METRIC_BIND = "/run/anubis/anubis-${name}/metrics.sock"; - TARGET = conf.target; + TARGET = " "; # Subrequest authentification. COOKIE_DOMAIN = conf.hostname; # TODO: db pour mettre en commun les token. # Transitoirement on les sépare diff --git a/modules/services/reverseproxy.nix b/modules/services/reverseproxy.nix index 6d8e28f..fb64fd0 100644 --- a/modules/services/reverseproxy.nix +++ b/modules/services/reverseproxy.nix @@ -157,7 +157,6 @@ in instances = lib.mapAttrs (vhostName: vhostConfig: { hostname = mkHostName vhostName mainTld; bind = "/run/anubis/anubis-${vhostName}/socket.sock"; - target = "unix:/run/nginx/nginx-${vhostName}.sock"; bots = vhostConfig.anubisConfig; }) (lib.filterAttrs (_: c: c.anubisConfig != null) cfg.virtualHosts); }; @@ -203,32 +202,6 @@ in acmeRoot = null; }; - # Conf pour l’hôte en entrée - entryExtraConf = { - extraConfig = '' - set_real_ip_from 172.16.0.0/16; - set_real_ip_from fd00::/56; - real_ip_header X-Real-Ip; - ''; - } - // sslConf; - # Conf supplémentaire pour le proxy principal - vhostExtraConf = - if vhostConfig.anubisConfig != null then - # Il reçoit les requêtes d’Anubis - { - listen = [ - { addr = "unix:/run/nginx/nginx-${vhostName}.sock"; } - ]; - extraConfig = '' - set_real_ip_from unix:; - real_ip_header X-Real-IP; - ''; - } - else - # Il est en entrée - entryExtraConf; - logHostConf = '' access_log /var/log/nginx/host/${vhostName}/access.log; error_log /var/log/nginx/host/${vhostName}/error.log; @@ -249,37 +222,52 @@ in in { # Configuration du service à proxy. - "${vhostName}" = vhostExtraConf // { + "${vhostName}" = sslConf // { serverName = hostname; - locations."/" = mkIf (vhostConfig.proxyPass != null) { - proxyPass = "http://${vhostConfig.proxyPass}"; - proxyWebsockets = vhostConfig.proxyWebsockets; - }; + + # Site statiques et alias root = vhostConfig.serveLocalFiles; globalRedirect = vhostConfig.globalRedirect; - extraConfig = vhostExtraConf.extraConfig + logHostConf; - }; - - # Entrée d’Anubis - "${vhostName}-anubis" = mkIf (vhostConfig.anubisConfig != null) ( - entryExtraConf - // rec { - serverName = hostname; - locations."/" = { - proxyPass = "http://unix:/run/anubis/anubis-${vhostName}/socket.sock"; + locations = { + # Entrée site, via proxy + "/" = mkIf (vhostConfig.proxyPass != null) { + proxyPass = "http://${vhostConfig.proxyPass}"; proxyWebsockets = vhostConfig.proxyWebsockets; - }; - locations."/.within.website/x/cmd/anubis/api/honeypot/" = locations."/" // { - extraConfig = '' - add_header 'X-Robots-Tag' 'noindex,nofollow' always; + extraConfig = lib.optionalString (vhostConfig.anubisConfig != null) '' + auth_request /.within.website/x/cmd/anubis/api/check; + error_page 401 = @redirectToAnubis; ''; }; - extraConfig = entryExtraConf.extraConfig + '' - access_log /var/log/nginx/anubis/access.log; - error_log /var/log/nginx/anubis/error.log; - ''; - } - ); + # Anubis + "/.within.website/" = mkIf (vhostConfig.anubisConfig != null) { + # https://anubis.techaro.lol/docs/admin/configuration/subrequest-auth/ + proxyPass = "http://unix:/run/anubis/anubis-${vhostName}/socket.sock"; + extraConfig = '' + proxy_pass_request_body off; + proxy_set_header content-length ""; + add_header 'X-Robots-Tag' 'noindex,nofollow' always; + auth_request off; + access_log /var/log/nginx/anubis/access.log; + error_log /var/log/nginx/anubis/error.log; + ''; + }; + "@redirectToAnubis" = mkIf (vhostConfig.anubisConfig != null) { + extraConfig = '' + return 307 /.within.website/?redir=$scheme://$host$request_uri; + auth_request off; + access_log /var/log/nginx/anubis/access.log; + error_log /var/log/nginx/anubis/error.log; + ''; + }; + }; + + extraConfig = '' + set_real_ip_from 172.16.0.0/16; + set_real_ip_from fd00::/56; + real_ip_header X-Real-Ip; + '' + + logHostConf; + }; } # Les alias // lib.mergeAttrsList ( From 9aa3a3122ea4af23461d086f9f26408b5eeb32ff Mon Sep 17 00:00:00 2001 From: Pyjacpp Date: Sun, 1 Nov 2026 23:39:00 +0100 Subject: [PATCH 3/4] =?UTF-8?q?anubis=E2=80=AF:=20DB=20pour=20les=20secret?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/crans/anubis.nix | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/modules/crans/anubis.nix b/modules/crans/anubis.nix index e14355e..09ed2de 100644 --- a/modules/crans/anubis.nix +++ b/modules/crans/anubis.nix @@ -1,6 +1,7 @@ { config, lib, + pkgs, ... }: let @@ -16,6 +17,7 @@ in { options.crans.anubis = { enable = mkEnableOption "Configuration d’Anubis du Crans."; + useRedis = mkEnableOption "Utilisation de Redis pour sauvegarder les challenges"; instances = mkOption { type = types.attrsOf ( types.submodule { @@ -62,6 +64,18 @@ in CHALLENGE = 200; DENY = 403; }; + logging = { + sink = "stdio"; + level = "WARN"; + }; + store = + let + redCfg = config.services.redis.servers.anubis; + in + { + backend = "valkey"; + parameters.url = "redis://${redCfg.bind}:${toString redCfg.port}/0"; + }; }; extraBots = [ { @@ -94,8 +108,7 @@ in METRIC_BIND = "/run/anubis/anubis-${name}/metrics.sock"; TARGET = " "; # Subrequest authentification. COOKIE_DOMAIN = conf.hostname; - # TODO: db pour mettre en commun les token. - # Transitoirement on les sépare + # XXX: Impossible de mettre en commun les challenges inter-sites ? COOKIE_PREFIX = "anubis-${conf.hostname}"; REDIRECT_DOMAINS = conf.hostname; SOCKET_MODE = "0660"; @@ -104,5 +117,16 @@ in }; }) cfg.instances; }; + + services.redis = { + # Meilleure licence que Redis + package = pkgs.valkey; + servers.anubis = { + enable = true; + bind = "127.0.0.1"; + port = 6379; + databases = 1; + }; + }; }; } From 24cc6783decc625f5246bc2ee09296694cfb2236 Mon Sep 17 00:00:00 2001 From: Pyjacpp Date: Wed, 11 Nov 2026 12:43:25 +0100 Subject: [PATCH 4/4] useRedis --- modules/crans/default.nix | 1 - modules/{crans => services}/anubis.nix | 7 ++++--- modules/services/default.nix | 1 + modules/services/reverseproxy.nix | 1 + 4 files changed, 6 insertions(+), 4 deletions(-) rename modules/{crans => services}/anubis.nix (95%) diff --git a/modules/crans/default.nix b/modules/crans/default.nix index 2dab786..4f28495 100644 --- a/modules/crans/default.nix +++ b/modules/crans/default.nix @@ -14,7 +14,6 @@ in { imports = [ ./age.nix - ./anubis.nix ./grub.nix ./home.nix ./locale.nix diff --git a/modules/crans/anubis.nix b/modules/services/anubis.nix similarity index 95% rename from modules/crans/anubis.nix rename to modules/services/anubis.nix index 09ed2de..9348b13 100644 --- a/modules/crans/anubis.nix +++ b/modules/services/anubis.nix @@ -72,7 +72,7 @@ in let redCfg = config.services.redis.servers.anubis; in - { + mkIf cfg.useRedis { backend = "valkey"; parameters.url = "redis://${redCfg.bind}:${toString redCfg.port}/0"; }; @@ -99,7 +99,8 @@ in } ] ++ conf.bots; - # Inclus via l’import de default-config.yaml. + # Inclus via l’import de default-config.yaml. Et on préfére mettre le + # whitelist Crans avant. useDefaultBotRules = false; }; settings = { @@ -122,7 +123,7 @@ in # Meilleure licence que Redis package = pkgs.valkey; servers.anubis = { - enable = true; + enable = cfg.useRedis; bind = "127.0.0.1"; port = 6379; databases = 1; diff --git a/modules/services/default.nix b/modules/services/default.nix index 2b1115a..97bfe4a 100644 --- a/modules/services/default.nix +++ b/modules/services/default.nix @@ -3,6 +3,7 @@ { imports = [ ./acme.nix + ./anubis.nix ./nginx.nix ./restic.nix ./reverseproxy.nix diff --git a/modules/services/reverseproxy.nix b/modules/services/reverseproxy.nix index fb64fd0..e3dc5c3 100644 --- a/modules/services/reverseproxy.nix +++ b/modules/services/reverseproxy.nix @@ -154,6 +154,7 @@ in # On active Anubis crans.anubis = { enable = true; + useRedis = true; instances = lib.mapAttrs (vhostName: vhostConfig: { hostname = mkHostName vhostName mainTld; bind = "/run/anubis/anubis-${vhostName}/socket.sock";