caddy: Replace option protocol with tls

This commit is contained in:
SebastianStork 2025-08-27 21:08:17 +02:00
parent 533f67e14b
commit db0569680e
2 changed files with 19 additions and 18 deletions

View file

@ -32,6 +32,13 @@
];
};
forgejo = {
enable = true;
doBackups = true;
domain = "git.sstork.dev";
ssh.enable = true;
};
hedgedoc = {
enable = true;
doBackups = true;
@ -43,31 +50,25 @@
domain = "tools.sprouted.cloud";
};
forgejo = {
enable = true;
doBackups = true;
domain = "git.sstork.dev";
ssh.enable = true;
};
openspeedtest = {
enable = true;
domain = "speedtest.sprouted.cloud";
};
caddy.virtualHosts = {
forgejo = {
inherit (config.custom.services.forgejo) domain port;
};
hedgedoc = {
inherit (config.custom.services.hedgedoc) domain port;
};
it-tools = {
inherit (config.custom.services.it-tools) domain port;
};
forgejo = {
inherit (config.custom.services.forgejo) domain port;
};
openspeedtest = {
inherit (config.custom.services.openspeedtest) domain port;
protocol = "http";
tls = false;
extraReverseProxyConfig = ''
request_buffers 35MiB
response_buffers 35MiB

View file

@ -63,12 +63,9 @@ in
type = lib.types.port;
default = null;
};
protocol = lib.mkOption {
type = lib.types.enum [
"https"
"http"
];
default = "https";
tls = lib.mkOption {
type = lib.types.bool;
default = true;
};
extraReverseProxyConfig = lib.mkOption {
type = lib.types.lines;
@ -95,7 +92,10 @@ in
virtualHosts =
virtualHosts
|> lib.mapAttrs' (
_: value: lib.nameValuePair "${value.protocol}://${value.domain}" (mkVirtualHostConfig value)
_: value:
lib.nameValuePair (lib.optionalString (!value.tls) "http://" + value.domain) (
mkVirtualHostConfig value
)
);
};
}