From a89b6b5afcf6759ce287f835bd575330f222cb59 Mon Sep 17 00:00:00 2001 From: ibizaman Date: Fri, 30 Dec 2022 01:49:41 -0800 Subject: [PATCH] move haproxy vaultwarden config to default.nix --- vaultwarden/default.nix | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/vaultwarden/default.nix b/vaultwarden/default.nix index 933284e..25a9856 100644 --- a/vaultwarden/default.nix +++ b/vaultwarden/default.nix @@ -1,9 +1,36 @@ { pkgs , utils }: -{ user ? "vaultwarden" +{ ingress ? 18005 +, user ? "vaultwarden" , group ? "vaultwarden" + +, distribution ? {} }: +let + addressOrLocalhost = distHaproxy: service: + if (builtins.head distHaproxy).properties.hostname == service.target.properties.hostname then + "127.0.0.1" + else + service.target.properties.hostname; +in { inherit user group; + + haproxy = service: { + frontend = { + acl = { + acl_vaultwarden = "hdr_beg(host) vaultwarden."; + }; + use_backend = "if acl_vaultwarden"; + }; + backend = { + servers = [ + { + name = "ttrss1"; + address = "${addressOrLocalhost distribution.HaproxyConfig service}:${builtins.toString ingress}"; + } + ]; + }; + }; } \ No newline at end of file