system/machines/magenta/services/traefik.nix

64 lines
1.6 KiB
Nix
Raw Normal View History

{ config, lib, ... }:
2023-03-04 23:22:03 +03:00
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;
};
users.groups.docker.members = [ "traefik" ];
2023-03-04 23:22:03 +03:00
services.traefik = {
enable = true;
staticConfigOptions = {
entryPoints = {
http = {
address = ":80";
http.redirections.entryPoint = {
to = "https";
scheme = "https";
};
};
2023-03-04 23:22:03 +03:00
https.address = ":443";
dashboard.address = ":8080";
};
api = { };
log = { };
accessLog = { };
certificatesResolvers.le.acme = {
storage = "${traefikCfg.dataDir}/acme.json";
email = "dmitriy@pleshevski.ru";
tlschallenge = true;
};
providers.docker = {
network = "rp_public";
constraints = "Label(`traefik.constraint-label`, `${config.networking.hostName}_public`)";
exposedByDefault = false;
swarmMode = true;
};
2023-03-04 23:22:03 +03:00
};
dynamicConfigOptions.http = {
routers.to_traefik_dashboard = {
rule = "Host(`${magentaData.addr}`)";
entryPoints = [ "dashboard" ];
middlewares = [ "traefik_dashboard_auth" ];
service = "api@internal";
};
middlewares = {
traefik_dashboard_auth.basicAuth = {
usersFile = config.age.secrets.traefik-dashboard-basicauth-users.path;
2023-03-04 23:22:03 +03:00
};
};
};
};
2023-03-04 23:22:03 +03:00
}