From 4c8d380e9eaa673b63b3d2167f8fa0a346e34591 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20=E2=80=9CNiols=E2=80=9D=20Jeannerod?= Date: Tue, 1 Oct 2024 18:18:47 +0200 Subject: [PATCH] Proxy all buckets that have `website = true` --- fediversity/garage.nix | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/fediversity/garage.nix b/fediversity/garage.nix index c334afc..5b1d32d 100644 --- a/fediversity/garage.nix +++ b/fediversity/garage.nix @@ -14,6 +14,7 @@ let inherit (builtins) toString; inherit (lib) types mkOption mkEnableOption optionalString concatStringsSep; inherit (lib.strings) escapeShellArg; + inherit (lib.attrsets) filterAttrs mapAttrs'; cfg = config.services.garage; fedicfg = config.fediversity.internal.garage; concatMapAttrs = scriptFn: attrset: concatStringsSep "\n" (lib.mapAttrsToList scriptFn attrset); @@ -159,16 +160,23 @@ in }; }; - services.nginx.virtualHosts.${fedicfg.web.domainForBucket "pixelfed"} = { - forceSSL = true; - enableACME = true; - locations."/" = { - proxyPass = "http://localhost:3902"; - extraConfig = '' - proxy_set_header Host $host; - ''; - }; - }; + ## Create a proxy from .web.garage. to localhost:3902 for + ## each bucket that has `website = true`. + services.nginx.virtualHosts = + let + value = { + forceSSL = true; + enableACME = true; + locations."/" = { + proxyPass = "http://localhost:3902"; + extraConfig = '' + proxy_set_header Host $host; + ''; + }; + }; + in mapAttrs' + (bucket: _: {name = fedicfg.web.domainForBucket bucket; inherit value;}) + (filterAttrs (_: {website, ...}: website) cfg.ensureBuckets); systemd.services.ensure-garage = { after = [ "garage.service" ];