2023-03-09 14:15:44 +03:00
|
|
|
{ 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;
|
|
|
|
};
|
|
|
|
|
2023-03-09 14:15:44 +03:00
|
|
|
users.groups.docker.members = [ "traefik" ];
|
|
|
|
|
2023-03-04 23:22:03 +03:00
|
|
|
services.traefik = {
|
|
|
|
enable = true;
|
|
|
|
staticConfigOptions = {
|
|
|
|
entryPoints = {
|
2023-03-05 16:09:24 +03:00
|
|
|
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;
|
|
|
|
};
|
2023-03-09 14:15:44 +03:00
|
|
|
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
|
|
|
};
|
2023-03-09 14:15:44 +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-09 14:15:44 +03:00
|
|
|
|
2023-03-04 23:22:03 +03:00
|
|
|
}
|