2022-12-30 10:44:55 +01:00
|
|
|
{ pkgs
|
|
|
|
, utils
|
|
|
|
}:
|
2022-12-30 10:49:41 +01:00
|
|
|
{ ingress ? 18005
|
|
|
|
, user ? "vaultwarden"
|
2022-12-30 10:44:55 +01:00
|
|
|
, group ? "vaultwarden"
|
2022-12-30 10:49:41 +01:00
|
|
|
|
|
|
|
, distribution ? {}
|
2022-12-30 10:44:55 +01:00
|
|
|
}:
|
2022-12-30 10:49:41 +01:00
|
|
|
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
|
2022-12-30 10:44:55 +01:00
|
|
|
{
|
|
|
|
inherit user group;
|
2022-12-30 10:49:41 +01:00
|
|
|
|
|
|
|
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}";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2022-12-30 10:44:55 +01:00
|
|
|
}
|