From 4f3c68b08ec4a07fea18c34134a45e29e0f80050 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Tue, 27 Apr 2021 10:10:17 +0200 Subject: [PATCH] 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 --- hosts/parsons/configuration.nix | 1 + services/shortdomains.nix | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 services/shortdomains.nix diff --git a/hosts/parsons/configuration.nix b/hosts/parsons/configuration.nix index c41dfa0..23b10d3 100644 --- a/hosts/parsons/configuration.nix +++ b/hosts/parsons/configuration.nix @@ -21,6 +21,7 @@ ../../services/gitlab-runner.nix ../../services/unifi.nix ../../services/lantifa.nix + ../../services/shortdomains.nix ./lxc.nix ]; diff --git a/services/shortdomains.nix b/services/shortdomains.nix new file mode 100644 index 0000000..2f24d8c --- /dev/null +++ b/services/shortdomains.nix @@ -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") + ]; +}