2021-04-27 08:10:17 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
shortdomain = "i4f.de";
|
2021-10-07 16:04:25 +00:00
|
|
|
redirects = [
|
|
|
|
(short "d" "discuss.infra4future.de")
|
|
|
|
(short "m" "mattermost.infra4future.de")
|
|
|
|
(short "c" "cloud.infra4future.de")
|
|
|
|
(short "s" "survey.infra4future.de")
|
|
|
|
(short "g" "gitlab.infra4future.de")
|
|
|
|
];
|
|
|
|
|
|
|
|
|
2021-05-03 10:08:25 +00:00
|
|
|
short = name: target: {
|
|
|
|
inherit name target;
|
|
|
|
};
|
|
|
|
toVirtualHosts = {name, target, ...}: {
|
|
|
|
name = "${name}.${shortdomain}";
|
2021-04-27 08:10:17 +00:00
|
|
|
value = {
|
|
|
|
forceSSL = true;
|
2021-10-07 16:04:25 +00:00
|
|
|
useACMEHost = "*.i4f.de";
|
2021-05-03 09:50:37 +00:00
|
|
|
locations."/".return = "302 https://${target}$request_uri";
|
2021-04-27 08:10:17 +00:00
|
|
|
};
|
|
|
|
};
|
2021-05-03 10:08:25 +00:00
|
|
|
in
|
|
|
|
{
|
2021-10-07 16:04:25 +00:00
|
|
|
security.acme.certs."wildcard.i4f.de" = {
|
|
|
|
domain = "*.i4f.de";
|
|
|
|
dnsProvider = "cloudflare";
|
|
|
|
credentialsFile = "/persist/var/shortdomains/dns-secrents.env";
|
|
|
|
};
|
|
|
|
|
2021-05-03 10:08:25 +00:00
|
|
|
services.nginx.virtualHosts =
|
|
|
|
lib.listToAttrs (map toVirtualHosts redirects)
|
|
|
|
// {
|
|
|
|
${shortdomain} = {
|
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
|
|
|
root = pkgs.writeText "index.html" ''
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<title>Infra4future shortlinks</title>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
</head>
|
|
|
|
<body><h1>Shortlinks for infra4future.de</h1>
|
|
|
|
${lib.strings.concatStrings
|
|
|
|
(map ({name, target,...}:
|
|
|
|
''
|
|
|
|
<p>
|
|
|
|
<a href="https://${target}">${name}.${shortdomain} → ${target}</a>
|
|
|
|
</p>
|
|
|
|
'')
|
|
|
|
redirects)
|
|
|
|
}
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2021-04-27 08:10:17 +00:00
|
|
|
}
|