Compare commits
5 commits
main
...
feature/sh
Author | SHA1 | Date | |
---|---|---|---|
5e7c46a4e9 | |||
9eed435ea3 | |||
e07d23e2ee | |||
03ce987c90 | |||
98c3c807c4 |
2 changed files with 61 additions and 0 deletions
|
@ -22,6 +22,7 @@
|
||||||
../../services/unifi.nix
|
../../services/unifi.nix
|
||||||
../../services/lantifa.nix
|
../../services/lantifa.nix
|
||||||
../../services/vaultwarden.nix
|
../../services/vaultwarden.nix
|
||||||
|
../../services/shortdomains.nix
|
||||||
|
|
||||||
./lxc.nix
|
./lxc.nix
|
||||||
];
|
];
|
||||||
|
|
60
services/shortdomains.nix
Normal file
60
services/shortdomains.nix
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
shortdomain = "i4f.de";
|
||||||
|
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")
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
short = name: target: {
|
||||||
|
inherit name target;
|
||||||
|
};
|
||||||
|
toVirtualHosts = {name, target, ...}: {
|
||||||
|
name = "${name}.${shortdomain}";
|
||||||
|
value = {
|
||||||
|
forceSSL = true;
|
||||||
|
useACMEHost = "*.i4f.de";
|
||||||
|
locations."/".return = "302 https://${target}$request_uri";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
security.acme.certs."wildcard.i4f.de" = {
|
||||||
|
domain = "*.i4f.de";
|
||||||
|
dnsProvider = "cloudflare";
|
||||||
|
credentialsFile = "/persist/var/shortdomains/dns-secrents.env";
|
||||||
|
};
|
||||||
|
|
||||||
|
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>
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue