feat(redirections): Add more precise redirection for retired websites, to make analytics relevant

This commit is contained in:
Tom Hubrecht 2024-02-14 11:15:46 +01:00
parent a52b61cb28
commit 054f98fc34
2 changed files with 20 additions and 21 deletions

View file

@ -9,7 +9,11 @@ let
builtins.map builtins.map
(name: { (name: {
inherit name; inherit name;
value.to = retired_host; value = {
enableACME = true;
forceSSL = true;
locations."/".return = "301 https://${retired_host}/${name}";
};
}) })
hosts hosts
); );
@ -17,6 +21,15 @@ let
mkSub = domain: builtins.map (s: "${s}.${domain}"); mkSub = domain: builtins.map (s: "${s}.${domain}");
mkSubs = attrs: builtins.concatLists (builtins.attrValues (builtins.mapAttrs mkSub attrs)); mkSubs = attrs: builtins.concatLists (builtins.attrValues (builtins.mapAttrs mkSub attrs));
mkRedirection =
_:
{ to }:
{
globalRedirect = to;
enableACME = true;
forceSSL = true;
};
redirections = { redirections = {
"calendrier.eleves.ens.fr".to = "calendrier.dgnum.eu"; "calendrier.eleves.ens.fr".to = "calendrier.dgnum.eu";
"docs.beta.rz.ens.wtf".to = "pads.dgnum.eu"; "docs.beta.rz.ens.wtf".to = "pads.dgnum.eu";
@ -26,7 +39,7 @@ let
"rdv.dgnum.eu".to = "meet.dgnum.eu"; "rdv.dgnum.eu".to = "meet.dgnum.eu";
"www.bda.ens.fr".to = "bda.ens.fr"; "www.bda.ens.fr".to = "bda.ens.fr";
"bda.wp.dgnum.eu".to = "bda.ens.fr"; "bda.wp.dgnum.eu".to = "bda.ens.fr";
} // (mkRetired retired); };
retired = mkSubs { retired = mkSubs {
"ens.fr" = [ "ens.fr" = [
@ -53,23 +66,7 @@ let
}; };
in in
{ {
services.nginx.virtualHosts = services.nginx.virtualHosts = {
{
${retired_host}.default = true; ${retired_host}.default = true;
} } // (builtins.mapAttrs mkRedirection redirections) // (mkRetired retired);
// (builtins.mapAttrs
(
_:
{
to,
ssl ? true,
}:
{
globalRedirect = to;
enableACME = ssl;
forceSSL = ssl;
}
)
redirections
);
} }

View file

@ -23,6 +23,8 @@ in
services.nginx.virtualHosts = recursiveUpdate (builtins.mapAttrs mkVhost websites) { services.nginx.virtualHosts = recursiveUpdate (builtins.mapAttrs mkVhost websites) {
"eleves.dgnum.eu".locations."/".tryFiles = "$uri $uri/index.html /fr/$uri /en/$uri /fr/index.html"; "eleves.dgnum.eu".locations."/".tryFiles = "$uri $uri/index.html /fr/$uri /en/$uri /fr/index.html";
"retired.dgnum.eu".locations."/".tryFiles = "/index.html =404";
"simi.normalesup.eu" = { "simi.normalesup.eu" = {
enableACME = true; enableACME = true;
forceSSL = true; forceSSL = true;