Fixing the reverse proxy alias configuration

reverseproxy-fix
Lyes Saadi 2025-12-21 12:26:11 +01:00 committed by Pyjacpp
parent 0922bbd0d6
commit 73a5d4aeb9
No known key found for this signature in database
GPG Key ID: ED479A5A26930939
1 changed files with 27 additions and 13 deletions

View File

@ -168,22 +168,36 @@ in
];
}) cfg.virtualHosts;
# Configuration des alias .fr et .eu
aliasConfig = lib.fold (
# Génération des alias
getAliases = name: config: lib.fold (
tld: acc:
acc
// lib.mapAttrs' (
vhostName: vhostConfig:
lib.nameValuePair "${vhostName}-alias-${tld}" rec {
rejectSSL = vhostConfig.httpOnly;
forceSSL = !rejectSSL;
enableACME = !rejectSSL;
serverName = "${vhostName}.crans.${tld}";
serverAliases = map (name: "${name}.crans.${tld}") vhostConfig.serverAliases;
globalRedirect = "${vhostName}.crans.${mainTld}";
++
(lib.fold (alias: acc: acc ++ ["${alias}.crans.${tld}"]) ["${name}.crans.${tld}"] config.serverAliases)
)
(lib.fold (alias: acc: acc ++ ["${alias}.crans.${mainTld}"]) [] config.serverAliases)
otherTld;
# Configuration des alias
aliasConfig = lib.fold (
vhost: acc:
acc
//
lib.fold (
alias: acc:
acc
//
{
"${vhost.name}-alias-${alias}" = rec {
rejectSSL = vhost.value.httpOnly;
forceSSL = !rejectSSL;
enableACME = !rejectSSL;
serverName = alias;
globalRedirect = "${vhost.name}.crans.${mainTld}";
};
}
) cfg.virtualHosts
) { } otherTld;
) { } (getAliases vhost.name vhost.value)
) { } (lib.attrsToList cfg.virtualHosts);
in
{
enable = true;