system/machines/magenta/services/traefik.nix

55 lines
1.3 KiB
Nix
Raw Normal View History

2023-03-04 23:22:03 +03:00
{ config, ... }:
let
traefikCfg = config.services.traefik;
magentaData = import ../data.secret.nix;
in
{
networking.firewall.allowedTCPPorts = [ 80 443 8080 ];
age.secrets.traefik-dashboard-basicauth-users = {
file = ../../../secrets/traefik-dashboard-basicauth-users.age;
owner = "traefik";
inherit (traefikCfg) group;
};
services.traefik = {
enable = true;
staticConfigOptions = {
entryPoints = {
http.address = ":80";
https.address = ":443";
dashboard.address = ":8080";
};
api = { };
log = { };
accessLog = { };
certificatesResolvers.le.acme = {
storage = "${traefikCfg.dataDir}/acme.json";
email = "dmitriy@pleshevski.ru";
tlschallenge = true;
};
};
dynamicConfigOptions = {
http = {
routers.to_traefik_dashboard = {
rule = "Host(`${magentaData.addr}`)";
entryPoints = [ "dashboard" ];
middlewares = [ "traefik_dashboard_auth" ];
service = "api@internal";
};
middlewares = {
https_redirect.redirectScheme = {
scheme = "https";
permanent = true;
};
traefik_dashboard_auth.basicAuth = {
usersFile = config.age.secrets.traefik-dashboard-basicauth-users.path;
};
};
};
};
};
}