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
This commit is contained in:
stuebinm 2021-04-27 10:10:17 +02:00
parent 20398cf2c8
commit 4f3c68b08e
No known key found for this signature in database
GPG key ID: 8FBE8AAD32FA12B7
2 changed files with 20 additions and 0 deletions

View file

@ -21,6 +21,7 @@
../../services/gitlab-runner.nix
../../services/unifi.nix
../../services/lantifa.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")
];
}