Files
Lars Nolden 58155dc737
check / flake-check (push) Successful in 25s
deploy / deploy (push) Successful in 48s
switch to emqx
2026-07-02 15:19:59 +02:00

41 lines
1005 B
Nix

{ config, lib, pkgs, ... }:
let
cfg = config.services.gebos.caddy;
# HTTP-style sites: static file server or reverse proxy.
siteBlock = host: site:
if site ? staticRoot then ''
${host} {
root * ${site.staticRoot}
file_server
try_files {path} /index.html
encode zstd gzip
}
''
else if site ? upstream then ''
${host} {
reverse_proxy ${site.upstream}
encode zstd gzip
}
''
else throw "site `${host}` needs one of: staticRoot, upstream";
in
{
options.services.gebos.caddy = {
enable = lib.mkEnableOption "Gebos Caddy reverse proxy / TLS terminator";
sites = lib.mkOption {
type = lib.types.attrsOf lib.types.attrs;
default = { };
};
};
config = lib.mkIf cfg.enable {
services.caddy = {
enable = true;
email = "ops@gebos.online"; # TODO: confirm ACME contact
extraConfig = lib.concatStringsSep "\n" (lib.mapAttrsToList siteBlock cfg.sites);
};
};
}