Load balancers

router.loadBalancers: services on several hosts (HAProxy) with HTTP
checks, TLS terminated on the router or passed through, the client in
X-Forwarded-For or the PROXY protocol, host names that choose a service
on a shared port and are published in the local DNS. A status page lists
the backends.
This commit is contained in:
2026-11-27 20:54:45 +01:00
parent 2aa70630d4
commit 553361f811
16 changed files with 1349 additions and 3 deletions
+14
View File
@@ -62,6 +62,19 @@ let
setOf = xs: "{ ${lib.concatMapStringsSep ", " toString xs} }";
# Load balancers listen on the router: their port is open in their zones.
lbInput = lib.concatLists (
lib.mapAttrsToList (
name: lb:
let
devs = lib.unique (
lib.concatMap (z: if z == "wan" then uplinks else zoneDevices z) lb.listen.zones
);
in
lib.optional (devs != [ ]) "iifname ${set devs} tcp dport ${toString lb.listen.port} accept # load balancer ${name}"
) cfg.loadBalancers
);
# Layer 4 match; `ports` and `sports` may be ints or "a-b" ranges.
l4 =
proto: ports: sports:
@@ -261,6 +274,7 @@ in
lib.concatMapStringsSep ", " toString listenPorts
} } accept # wireguard"
}
${lib.concatStringsSep "\n " lbInput}
${lib.optionalString (dhcpIfaces != [ ]) "iifname ${set dhcpIfaces} udp dport 67 accept"}
${lib.optionalString (mgmtIfaces != [ ]) "iifname ${set mgmtIfaces} tcp dport { ${
lib.concatMapStringsSep ", " toString ([ 22 ] ++ config.router.managementPorts)