Update Traefik with Cloudflare credentials

This commit is contained in:
2026-02-04 12:16:44 -06:00
parent 1214f72958
commit 713635d04f
+110 -62
View File
@@ -1,9 +1,9 @@
# Traefik Reverse Proxy # Traefik Reverse Proxy for hobbs.farm
# Deploy: nomad job run traefik.nomad.hcl # Deploy: nomad job run traefik.nomad.hcl
job "traefik" { job "traefik" {
datacenters = ["hf-dc1"] datacenters = ["hf-dc1"]
type = "system" # Runs on every client node type = "system"
group "traefik" { group "traefik" {
network { network {
@@ -13,27 +13,28 @@ job "traefik" {
port "https" { port "https" {
static = 443 static = 443
} }
port "dashboard" { port "api" {
static = 8080 static = 8088
} }
} }
volume "traefik-data" {
type = "host"
source = "traefik-data"
read_only = false
}
service { service {
name = "traefik" name = "traefik"
port = "https" port = "https"
tags = ["reverse-proxy", "traefik"]
tags = [
"traefik.enable=true",
"traefik.http.routers.dashboard.rule=Host(`traefik.hobbs.farm`)",
"traefik.http.routers.dashboard.service=api@internal",
]
check { check {
type = "http" type = "http"
path = "/ping" path = "/ping"
port = "dashboard" port = "api"
interval = "10s" interval = "10s"
timeout = "2s" timeout = "3s"
} }
} }
@@ -43,72 +44,119 @@ job "traefik" {
config { config {
image = "traefik:v3.0" image = "traefik:v3.0"
network_mode = "host" network_mode = "host"
volumes = [ volumes = [
"local/traefik.yml:/etc/traefik/traefik.yml:ro", "local/traefik.yml:/etc/traefik/traefik.yml:ro",
"local/dynamic:/etc/traefik/dynamic:ro", "local/dynamic:/etc/traefik/dynamic:ro",
] ]
} }
volume_mount {
volume = "traefik-data"
destination = "/data"
}
template { template {
destination = "local/traefik.yml" destination = "local/traefik.yml"
data = <<-EOF data = <<-EOF
api:
dashboard: true
insecure: true
ping:
entryPoint: api
entryPoints:
web:
address: ":80"
http:
redirections:
entryPoint:
to: websecure
scheme: https
websecure:
address: ":443"
api: api:
dashboard: true address: ":8088"
insecure: true
providers:
ping: consulCatalog:
entryPoint: dashboard prefix: traefik
exposedByDefault: false
entryPoints: endpoint:
web: address: 127.0.0.1:8500
address: ":80" file:
http: directory: /etc/traefik/dynamic
redirections: watch: true
entryPoint:
to: websecure certificatesResolvers:
scheme: https letsencrypt:
websecure: acme:
address: ":443" email: jeremy@hobbs.farm
dashboard: storage: /data/acme.json
address: ":8080" dnsChallenge:
provider: cloudflare
providers: resolvers:
consulCatalog: - "1.1.1.1:53"
prefix: traefik - "8.8.8.8:53"
exposedByDefault: false
endpoint: log:
address: 127.0.0.1:8500 level: INFO
file:
directory: /etc/traefik/dynamic accessLog: {}
watch: true
certificatesResolvers:
letsencrypt:
acme:
email: jeremydanielhobbs@gmail.com
storage: /etc/traefik/acme.json
dnsChallenge:
provider: cloudflare
resolvers:
- "1.1.1.1:53"
- "8.8.8.8:53"
log:
level: INFO
accessLog: {}
EOF EOF
} }
template { template {
destination = "local/dynamic/.keep" destination = "local/dynamic/media.yml"
data = "# Dynamic config directory" data = <<-EOF
http:
routers:
jellyfin:
rule: "Host(`r2d2.hobbs.farm`)"
entryPoints:
- websecure
service: jellyfin
tls:
certResolver: letsencrypt
sonarr:
rule: "Host(`sonarr.hobbs.farm`)"
entryPoints:
- websecure
service: sonarr
tls:
certResolver: letsencrypt
radarr:
rule: "Host(`radarr.hobbs.farm`)"
entryPoints:
- websecure
service: radarr
tls:
certResolver: letsencrypt
services:
jellyfin:
loadBalancer:
servers:
- url: "http://192.168.86.192:8096"
sonarr:
loadBalancer:
servers:
- url: "http://192.168.86.192:8989"
radarr:
loadBalancer:
servers:
- url: "http://192.168.86.192:7878"
EOF
} }
# Cloudflare credentials for Let's Encrypt DNS challenge
env { env {
CF_API_EMAIL = "" # Set via Nomad variables or Vault CF_DNS_API_TOKEN = "PWhuBvaYrh85S-iwBqQz4HFZV4c645znc8_eG7V9"
CF_API_KEY = "" # Set via Nomad variables or Vault
} }
resources { resources {