Compare commits

...

2 commits

Author SHA1 Message Date
sinavir
53379c88de feat(pub.dgnum.eu): Add a redirect toward instagram
All checks were successful
Check meta / check_meta (push) Successful in 17s
Check meta / check_dns (push) Successful in 19s
build configuration / build_storage01 (push) Successful in 1m12s
build configuration / build_vault01 (push) Successful in 1m13s
build configuration / build_compute01 (push) Successful in 1m17s
build configuration / build_web02 (push) Successful in 1m18s
lint / check (push) Successful in 23s
build configuration / build_web01 (push) Successful in 1m55s
build configuration / build_geo01 (push) Successful in 1m9s
build configuration / build_geo02 (push) Successful in 1m10s
build configuration / build_rescue01 (push) Successful in 1m12s
build configuration / build_bridge01 (push) Successful in 1m6s
build configuration / push_to_cache_storage01 (push) Successful in 1m23s
build configuration / push_to_cache_geo01 (push) Successful in 1m19s
build configuration / push_to_cache_web02 (push) Successful in 1m39s
build configuration / push_to_cache_compute01 (push) Successful in 1m55s
build configuration / push_to_cache_geo02 (push) Successful in 1m12s
build configuration / push_to_cache_bridge01 (push) Successful in 1m16s
build configuration / push_to_cache_rescue01 (push) Successful in 1m38s
build configuration / push_to_cache_vault01 (push) Successful in 1m39s
build configuration / push_to_cache_web01 (push) Successful in 1m59s
2024-09-30 20:17:20 +02:00
sinavir
626577e2bc feat(redirections): Make it more flexible to allow temporary redirects 2024-09-30 20:17:20 +02:00
6 changed files with 85 additions and 8 deletions

View file

@ -187,7 +187,7 @@ in
];
};
dgn-redirections.redirections."dgsi.dgnum.eu" = "profil.dgnum.eu";
dgn-redirections.permanent."dgsi.dgnum.eu" = "profil.dgnum.eu";
services = {
postgresql = {

View file

@ -1,6 +1,6 @@
{
dgn-redirections = {
redirections = {
permanent = {
"www.lanuit.ens.fr" = "lanuit.ens.fr";
"lanuit.ens.psl.eu" = "lanuit.ens.fr";
"www.lanuit.ens.psl.eu" = "lanuit.ens.fr";

View file

@ -14,7 +14,7 @@ in
dgn-redirections = {
inherit retiredHost;
redirections = {
permanent = {
"calendrier.eleves.ens.fr" = "calendrier.dgnum.eu";
"docs.beta.rz.ens.wtf" = "pads.dgnum.eu";
"git.rz.ens.wtf" = "git.dgnum.eu";
@ -32,6 +32,10 @@ in
"www.lanuit.ens.fr" = "lanuit.ens.fr";
};
temporary = {
"pub.dgnum.eu".to = "https://www.instagram.com/dgnum_eu/";
};
retired = mkSubs {
"ens.fr" = [
"alevins"

View file

@ -126,7 +126,7 @@ in
};
};
dgn-redirections.redirections."cas-eleves.dgnum.eu" = "cas.eleves.ens.fr";
dgn-redirections.permanent."cas-eleves.dgnum.eu" = "cas.eleves.ens.fr";
services = {
postgresql = {

View file

@ -103,6 +103,7 @@ let
"netbox" # Netbox
"podcasts" # Castopod
"push" # Ntfy.sh
"pub" # Url de promotion (qrcodes etc...)
# Static websites
"eleves"

View file

@ -3,7 +3,13 @@
let
inherit (lib) mkOption;
inherit (lib.types) attrsOf listOf str;
inherit (lib.types)
attrsOf
ints
listOf
str
submodule
;
mkRetired =
hosts:
@ -18,19 +24,33 @@ let
}) hosts
);
mkRedirection = _: globalRedirect: {
mkPermanent = _: globalRedirect: {
inherit globalRedirect;
enableACME = true;
forceSSL = true;
};
mkTemporary =
_:
{
to,
code,
location,
}:
{
enableACME = true;
forceSSL = true;
locations.${location}.return = "${toString code} ${to}";
};
cfg = config.dgn-redirections;
in
{
options.dgn-redirections = {
redirections = mkOption {
permanent = mkOption {
type = attrsOf str;
default = { };
description = ''
@ -40,6 +60,57 @@ in
'';
};
temporary = mkOption {
type = attrsOf (submodule {
options = {
to = mkOption {
type = str;
description = "Target of the redirection";
};
code = mkOption {
type = ints.between 300 399;
default = 302;
example = 308;
description = ''
HTTP status used by the redirection. Possible usecases
include temporary (302, 307) redirects, keeping the request method and
body (307, 308), or explicitly resetting the method to GET (303).
See <https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections>.
'';
};
location = mkOption {
type = str;
default = "/";
description = "nginx-style location for the source of the redirection";
};
};
});
default = { };
example = {
"source.dgnum.eu" = {
to = "https://target.dgnum.eu/path_to_page";
code = 307;
location = "/subpath/";
};
};
description = ''
Attribute set of temporary redirections. The attribute is the source
domain.
For:
```
{
"source.dgnum.eu" = {
to = "https://target.dgnum.eu/path_to_page";
code = 307;
};
}
```
a 307 redirect from all the urls within the domain `source.dgnum.eu` to
`https://target.dgnum.eu/path_to_page` will be made.
'';
};
retired = mkOption {
type = listOf str;
default = [ ];
@ -59,6 +130,7 @@ in
config = {
services.nginx.virtualHosts =
(builtins.mapAttrs mkRedirection cfg.redirections) // (mkRetired cfg.retired);
(builtins.mapAttrs mkPermanent cfg.permanent // builtins.mapAttrs mkTemporary cfg.temporary)
// (mkRetired cfg.retired);
};
}