extract custom caddy build to reverse-proxy module when used for host- or network-local access, the external modules are not required. Since the builder module is in NUR, this was causing evaluation failures on systems where NUR was not configured
1 file changed, 50 insertions(+), 0 deletions(-)
changed files
A system/roles/reverse-proxy.nix
@@ -0,0 +1,50 @@ +{ + pkgs, + ... +}: +{ + imports = [ + ../settings/configuration/nur.nix + ]; + + services.caddy = { + package = pkgs.nur.repos.xyenon.caddy.withPlugins { + plugins = [ + "github.com/caddyserver/cache-handler@v0.16.0" + "github.com/mholt/caddy-l4@v0.0.0-20260212155620-dd12cc413469" + "github.com/tailscale/caddy-tailscale@v0.0.0-20260106222316-bb080c4414ac" + ]; + hash = "sha256-A+wDNJijfD1pnOePXCVMXYzRNxf4Fmpbq2rJG+FMstM="; + }; + globalConfig = '' + cache + servers { + listener_wrappers { + layer4 { + @ssh ssh + route @ssh { + proxy localhost:22 + } + route + } + tls + } + } + tailscale { + tags tag:app + } + ''; + }; + + users.groups.webservice = { + members = [ "caddy" ]; + }; + systemd.tmpfiles.rules = [ + # setgid bit (2) + # sticky bit (4) + "d /run/web/ 6770 caddy webservice -" + ]; + systemd.services.caddy.serviceConfig = { + ReadWritePaths = [ "/run/web" ]; + }; +}