job "traefik" { datacenters = ["dc1"] type = "service" priority = 100 constraint { attribute = "${node.class}" value = "ingress" } constraint { distinct_hosts = true } update { max_parallel = 1 canary = 1 auto_promote = false auto_revert = true min_healthy_time = "30s" healthy_deadline = "5m" } group "traefik" { count = 2 network { port "web" { static = 80 } port "websecure" { static = 443 } port "syslog" { static = 514 } port "gitssh" { static = 2222 } port "metrics" {} dns { servers = [ "192.168.2.101", "192.168.2.102", "192.168.2.30", ] } } ephemeral_disk { migrate = true sticky = true } task "traefik" { driver = "docker" service { name = "traefik" provider = "nomad" port = "web" check { type = "http" path = "/ping" interval = "10s" timeout = "2s" } tags = [ "traefik.enable=true", "traefik.http.routers.traefik.entryPoints=websecure", "traefik.http.routers.traefik.service=api@internal", ] } service { name = "traefik-metrics" provider = "nomad" port = "metrics" tags = [ "prometheus.scrape", ] } config { image = "traefik:3.0" ports = ["web", "websecure", "syslog", "gitssh", "metrics"] network_mode = "host" mount { type = "bind" target = "/etc/traefik" source = "local/config" } mount { type = "bind" target = "/etc/traefik/usersfile" source = "secrets/usersfile" } mount { type = "bind" target = "/etc/traefik/certs" source = "secrets/certs" } } env = { TRAEFIK_PROVIDERS_NOMAD_ENDPOINT_TOKEN = "${NOMAD_TOKEN}" } identity { env = true } template { # Avoid conflict with TOML lists [[ ]] and Go templates {{ }} left_delimiter = "<<" right_delimiter = ">>" data = <>" [entryPoints.syslogtcp] address = ":514" [entryPoints.syslogudp] address = ":514/udp" [entryPoints.gitssh] address = ":2222" [api] dashboard = true [ping] entrypoint = "web" [metrics] [metrics.prometheus] entrypoint = "metrics" # manualRouting = true [providers.file] directory = "/etc/traefik/conf" watch = true [providers.nomad] exposedByDefault = false defaultRule = "Host(`{{normalize .Name}}.<< with nomadVar "nomad/jobs" >><< .base_hostname >><< end >>`)" [providers.nomad.endpoint] address = "unix:///secrets/api.sock" EOH destination = "${NOMAD_TASK_DIR}/config/traefik.toml" } template { data = <