shortcut domains for services

as per Zauberberg's idea in mattermost last night [1], this adds an
extra domain, which just exists to make links to the various services
shorter, using a nix to keep the whole thing easily changable.

In particular, the "shortdomain" binding should be set to some domain we
actually own before anyone deploys this (I've set it to "i4f.de" as a
dummy value for now).

Potential caveats:
 - this uses ACME to get a certificate for each of the redirect domains,
   which may run into rate limits if we have too many of them.
 - there's nothing on the shortdomain itself. I suggest we could either
   use it as a general linkshortener, or generate a list of available
   domain shortcuts into html from nix

[1] https://mattermost.infra4future.de/hacc/pl/xks5naezcbn8myh79bq3dehmso
keep-around/5e7c46a4e96150bf22b674d671362ada79a2247d
stuebinm 2021-04-27 10:10:17 +02:00
parent ad5d21cba5
commit 98c3c807c4
No known key found for this signature in database
GPG Key ID: 8FBE8AAD32FA12B7
2 changed files with 20 additions and 0 deletions

View File

@ -22,6 +22,7 @@
../../services/unifi.nix
../../services/lantifa.nix
../../services/vaultwarden.nix
../../services/shortdomains.nix
./lxc.nix
];

19
services/shortdomains.nix Normal file
View File

@ -0,0 +1,19 @@
{ config, lib, pkgs, ... }:
let
shortdomain = "i4f.de";
short = abbrv: target: {
name = "${abbrv}.${shortdomain}";
value = {
forceSSL = true;
enableACME = true;
locations."/".return = "301 https://${target}$request_uri";
};
};
in
{
services.nginx.virtualHosts = lib.listToAttrs [
(short "d" "discuss.infra4future.de")
(short "m" "mattermost.infra4future.de")
];
}