{ config, lib, ... }: with lib; let cfg = config.local.web; in { options.local.web = { enable = mkEnableOption "Local configuration of caddy"; projectRoot = mkOption { default = "/home/alan/projects"; type = types.str; description = "Where projects are stored"; }; }; config = mkIf cfg.enable { services.caddy = { enable = true; extraConfig = '' (local_tls) { tls { issuer internal { ca local } } } ''; virtualHosts = { "localhost" = { logFormat = "output discard"; extraConfig = '' import local_tls acme_server { allow { domains *.test *.localhost } } ''; }; "alin.localhost" = { logFormat = "output discard"; serverAliases = [ "alin.test" "alanpearce.test" "alanpearce.localhost" ]; extraConfig = '' import local_tls reverse_proxy http://localhost:8080 { transport http { dial_timeout 1s compression off } } ''; }; "elgit.localhost" = { logFormat = "output discard"; extraConfig = '' import local_tls reverse_proxy http://localhost:5555 { transport http { dial_timeout 1s compression off } } ''; }; "searchix.localhost" = { logFormat = "output discard"; extraConfig = '' import local_tls handle_errors { rewrite * /error.html templates file_server } handle { reverse_proxy http://localhost:3000 { transport http { dial_timeout 1s compression off } } } ''; }; "auth.localhost" = { logFormat = "output discard"; extraConfig = '' import local_tls reverse_proxy http://localhost:8082 ''; }; "xhain.localhost" = { logFormat = "output discard"; extraConfig = '' import local_tls root * /Users/alan/projects/github.com/xHain-hackspace/xhain-website/public/ file_server ''; }; "hugo.localhost" = { logFormat = "output discard"; extraConfig = '' import local_tls reverse_proxy http://localhost:1313 { transport http { dial_timeout 1s compression off } } ''; }; }; }; }; }