mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 17:31:34 +01:00
caddy: Allow for protocol selection
This commit is contained in:
parent
af9fd8b2c7
commit
5d2d29d16d
1 changed files with 21 additions and 8 deletions
|
|
@ -22,7 +22,9 @@ let
|
||||||
|
|
||||||
getSubdomain = domain: domain |> lib.splitString "." |> lib.head;
|
getSubdomain = domain: domain |> lib.splitString "." |> lib.head;
|
||||||
|
|
||||||
mkVirtualHostConfig = domain: port: {
|
mkVirtualHostConfig =
|
||||||
|
{ domain, port, ... }:
|
||||||
|
{
|
||||||
logFormat = "output file ${config.services.caddy.logDir}/access-${domain}.log { mode 640 }";
|
logFormat = "output file ${config.services.caddy.logDir}/access-${domain}.log { mode 640 }";
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
${lib.optionalString (isTailscaleDomain domain) "bind tailscale/${getSubdomain domain}"}
|
${lib.optionalString (isTailscaleDomain domain) "bind tailscale/${getSubdomain domain}"}
|
||||||
|
|
@ -54,6 +56,17 @@ in
|
||||||
type = lib.types.port;
|
type = lib.types.port;
|
||||||
default = null;
|
default = null;
|
||||||
};
|
};
|
||||||
|
protocol = lib.mkOption {
|
||||||
|
type = lib.types.enum [
|
||||||
|
"https"
|
||||||
|
"http"
|
||||||
|
];
|
||||||
|
default = "https";
|
||||||
|
};
|
||||||
|
extraReverseProxyConfig = lib.mkOption {
|
||||||
|
type = lib.types.lines;
|
||||||
|
default = "";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
@ -75,7 +88,7 @@ in
|
||||||
virtualHosts =
|
virtualHosts =
|
||||||
virtualHosts
|
virtualHosts
|
||||||
|> lib.mapAttrs' (
|
|> lib.mapAttrs' (
|
||||||
_: value: lib.nameValuePair value.domain (mkVirtualHostConfig value.domain value.port)
|
_: value: lib.nameValuePair "${value.protocol}://${value.domain}" (mkVirtualHostConfig value)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue