From b4ddbaa1baddaec5411e172e0823b6f5016c5545 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 16 Nov 2026 20:53:54 +0000 Subject: egress through nginx+lua, with path rules OpenResty replaces the plain nginx SNI proxy, and egress.lua decides by server name and the rules in /var/lib/fc-egress/allowed: DOMAIN passes the domain and its subdomains through without decrypting; DOMAIN/PREFIX decrypts, with certificates made on the fly from the host's own CA, and only forwards requests whose path starts with PREFIX. Upstream is always port 443 of the server name, as resolved by the host, and its certificate gets verified. The rules get read on every connection, so the path unit and reloads are gone. The CA certificate gets published as /var/lib/fcbr0-egress/ca.pem, and the guest trusts it when built on the host. --- default.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'default.nix') diff --git a/default.nix b/default.nix index 31af3c0..d553c73 100644 --- a/default.nix +++ b/default.nix @@ -1,5 +1,7 @@ { pkgs ? import {} , kernelPackages ? pkgs.linuxPackages_latest + # The CA of the host's egress proxy (see host.nix), if it's there. +, caCert ? "/var/lib/fcbr0-egress/ca.pem" }: let inherit (pkgs) lib; @@ -66,8 +68,10 @@ let networking.useDHCP = false; networking.resolvconf.enable = false; # The host resolves every name to itself and proxies TLS to allowed - # names, see host.nix. + # names, decrypting some with certificates from its CA, see host.nix. environment.etc."resolv.conf".text = "nameserver 172.16.0.1\n"; + security.pki.certificateFiles = + lib.optional (builtins.pathExists caCert) (/. + caCert); systemd.network.enable = true; systemd.network.wait-online.enable = false; systemd.network.networks.eth = { -- cgit v1.3.1