feat(garage): Simplify management of domains and buckets
All checks were successful
build configuration / build_vault01 (push) Successful in 1m4s
build configuration / build_web02 (push) Successful in 1m4s
build configuration / build_compute01 (push) Successful in 1m12s
build configuration / build_storage01 (push) Successful in 1m20s
lint / check (push) Successful in 23s
build configuration / build_web01 (push) Successful in 1m29s
build configuration / build_rescue01 (push) Successful in 48s

This commit is contained in:
Tom Hubrecht 2024-03-16 17:34:42 +01:00
parent f74fd8c8eb
commit 9cae38be02

View file

@ -1,9 +1,4 @@
{
config,
pkgs,
lib,
...
}:
{ config, pkgs, ... }:
let
host = "s3.dgnum.eu";
@ -12,16 +7,17 @@ let
data_dir = "/data/slow/garage/data";
metadata_dir = "/data/fast/garage/meta";
buckets = {
"castopod-dgnum" = { };
"peertube-videos-dgnum" = { };
"boussole-sante.normalesup.eu" = {
mainDomain = true;
};
"simi.normalesup.eu" = {
mainDomain = true;
};
};
domains = [
"boussole-sante.normalesup.eu"
"simi.normalesup.eu"
];
buckets = [
"castopod-dgnum"
"peertube-videos-dgnum"
] ++ domains;
mkHosted = host: builtins.map (b: "${b}.${host}");
in
{
services.garage = {
@ -79,7 +75,7 @@ in
enableACME = true;
forceSSL = true;
serverAliases = builtins.map (b: "${b}.${host}") (builtins.attrNames buckets);
serverAliases = mkHosted host buckets;
locations."/".extraConfig = ''
proxy_pass http://127.0.0.1:3900;
@ -95,16 +91,13 @@ in
enableACME = true;
forceSSL = true;
serverAliases = lib.flatten (
lib.mapAttrsToList (
b: v: lib.singleton "${b}.${webHost}" ++ lib.optional (v ? mainDomain && v.mainDomain) b
) buckets
);
serverAliases = domains ++ (mkHosted webHost buckets);
locations."/".extraConfig = ''
proxy_pass http://127.0.0.1:3902;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;'';
proxy_set_header Host $host;
'';
};
};
}