Add support to externeal subdomain

This commit is contained in:
= 2025-02-02 18:10:47 +01:00
parent e754d926eb
commit c3c23d3494
2 changed files with 46 additions and 0 deletions

View file

@ -133,6 +133,15 @@ in
cloudflareApiEnvName = "CLOUDFLARE_API_TOKEN";
}
];
extraVirtualHosts = [
{
subdomain = "h";
host = "http://ha.internal:8123";
domain = publicDomain;
}
];
};
ddclient = {

View file

@ -50,6 +50,32 @@ in
default = "";
};
# List of extra caddy.virtualHost
extraVirtualHosts = lib.mkOption {
type = lib.types.listOf (
lib.types.submodule {
options = {
subdomain = lib.mkOption {
type = lib.types.str;
description = "The subdomain for the virtual host.";
};
host = lib.mkOption {
type = lib.types.str;
description = "The host address for the reverse proxy.";
};
domain = lib.mkOption {
type = lib.types.str;
description = "The domain for the virtual host.";
};
};
}
);
description = ''
A list of virtual hosts outside nixos/colmena config.
'';
default = [ ];
};
};
config = lib.mkIf cfg.enable {
@ -134,6 +160,17 @@ in
) cfg.domainsList
);
virtualHosts = lib.foldl' (
acc: extraVirtualHost:
acc
// {
"${extraVirtualHost.subdomain}.${extraVirtualHost.domain}".extraConfig = ''
reverse_proxy ${extraVirtualHost.host}
import cloudflare_${extraVirtualHost.domain}
'';
}
) { } cfg.extraVirtualHosts;
};
systemd.services.caddy.serviceConfig = {