tvl-depot/ops/modules/www/self-redirect.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
632 B
Nix
Raw Normal View History

# Redirect the hostname of a machine to its configuration in a web
# browser.
#
# Works by convention, assuming that the machine has its configuration
# at //ops/machines/${hostname}.
{ config, ... }:
let
host = "${config.networking.hostName}.${config.networking.domain}";
in
{
imports = [
./base.nix
];
config.services.nginx.virtualHosts."${host}" = {
serverName = host;
addSSL = true; # SSL is not forced on these redirects
enableACME = true;
extraConfig = ''
location = / {
return 302 https://at.tvl.fyi/?q=%2F%2Fops%2Fmachines%2F${config.networking.hostName};
}
'';
};
}