You started with Traefik on one node, configuration written into /etc/traefik/dynamic.yml, certificates resolved by Let’s Encrypt and cached in acme.json next to it. That worked. You added a second node behind a cloud LB for capacity, copied the YAML over, and now half your routes 502 because the second node hasn’t been issued a cert and is racing the first node for the ACME order. The cache file is per-node; the routes are duplicated; nobody is the source of truth. Cluster mode for Traefik is what makes the second node a peer instead of a copy.
What’s happening
Traefik 3 is designed to read its dynamic configuration from one or more providers — file, Docker, Kubernetes, or a KV store like Consul or etcd. The static config (entrypoints, providers, certificate resolvers) is loaded at startup; the dynamic config (routers, services, middlewares, TLS options) is watched continuously, and changes propagate without restart. In single-node mode you can get away with the file provider. In cluster mode you cannot, for two reasons.
First, the certificate resolver state — ACME order tokens, issued certs, account keys — must be shared across nodes, or each node tries to solve the challenge independently and ACME rate-limits you within an afternoon. The KV provider with a distributed lock (acme.kvStore) gives you one resolver that owns issuance and all nodes that read the resulting bundle.
Second, the dynamic config itself wants a single source of truth. Editing dynamic.yml on three nodes and hoping rsync doesn’t lag is not a configuration strategy. With Consul KV (or etcd) you have one tree at traefik/http/routers/... that all three nodes watch via long-polling; one consul kv put and the change is live on every node within a couple of seconds, atomically.
Sticky sessions, request-level metrics, and observability are the third axis. Traefik 3’s responseModifierChain and passHostHeader defaults differ from v2; sticky cookies need an explicit cookie block on each service; Prometheus metrics include router and service breakdowns by default. Get this layer right at install time and you avoid retrofitting it after a customer reports a session-loss bug.
How to verify
After the installer runs on all three nodes plus the Consul cluster, the dashboard should be reachable on the admin port and show all three Traefik instances:
curl -fsS http://127.0.0.1:8080/api/version | jq
curl -fsS http://127.0.0.1:8080/api/overview | jq '.http.routers, .http.services'
Consul should see them as KV consumers, and the cert resolver should report a leader:
consul kv get -recurse traefik/ | head -40
consul kv get traefik/acme/account/lock
Push a test route into Consul and confirm it appears on every node:
consul kv put traefik/http/routers/test/rule "Host(\`test.example.com\`)"
consul kv put traefik/http/routers/test/service "test-svc"
consul kv put traefik/http/routers/test/entryPoints/0 "websecure"
consul kv put traefik/http/services/test-svc/loadBalancer/servers/0/url "http://10.30.0.50:8080"
for n in 10.30.0.11 10.30.0.12 10.30.0.13; do
ssh $n "curl -fsS http://127.0.0.1:8080/api/http/routers/test@consulcatalog | jq .status"
done
If one node reports disabled while others report enabled, that node lost its Consul lease — check journalctl -u traefik -n 200.
The fix
The installer is split into two scripts: a Consul cluster installer (run on three KV nodes) and the Traefik node installer (run on each Traefik front-end). For brevity assume the Consul cluster is already running at consul-01..03.internal:8500; if not, the snippet at the top of the Traefik installer drops one in.
Save the Traefik installer as /root/setup-traefik-cluster-node.sh:
#!/usr/bin/env bash
set -euo pipefail
### AlmaLinux 9 Traefik 3 cluster node installer (Consul KV provider)
### Run on each Traefik node after editing the variables below.
### Consul cluster must already exist at CONSUL_HOSTS or be installed via the snippet below.
if [[ "$(id -u)" -ne 0 ]]; then
echo "Run as root."
exit 1
fi
# === EDIT PER NODE ===
NODE_NAME="traefik-01"
NODE_IP="10.30.0.11"
CONSUL_HOSTS="10.30.0.21:8500,10.30.0.22:8500,10.30.0.23:8500"
CONSUL_PREFIX="traefik"
ACME_EMAIL="ops@example.com"
ACME_CASERVER="https://acme-v02.api.letsencrypt.org/directory"
DASHBOARD_USER="admin"
DASHBOARD_PASS="CHANGE_ME"
TRAEFIK_VERSION="3.2.1"
# =====================
echo
echo "========================================"
echo "Traefik cluster node ${NODE_NAME} (${NODE_IP})"
echo "========================================"
echo
echo "==> Updating base OS"
dnf -y update
dnf -y install epel-release
dnf -y install curl wget jq lsof tcpdump net-tools bind-utils tar gzip \
policycoreutils-python-utils fail2ban dnf-automatic chrony socat \
httpd-tools unzip
systemctl enable --now chronyd
echo "==> SELinux enforcing"
sed -i 's/^SELINUX=.*/SELINUX=enforcing/' /etc/selinux/config
setenforce 1 || true
echo "==> Hardening SSH"
sed -i 's|^[#[:space:]]*PermitRootLogin.*|PermitRootLogin prohibit-password|' /etc/ssh/sshd_config
sed -i 's|^[#[:space:]]*PasswordAuthentication.*|PasswordAuthentication no|' /etc/ssh/sshd_config
sshd -t && systemctl restart sshd
cat > /etc/fail2ban/jail.d/sshd.local <<'FAIL2BAN'
[sshd]
enabled = true
port = ssh
backend = systemd
maxretry = 4
findtime = 10m
bantime = 1h
FAIL2BAN
systemctl enable --now fail2ban
cat > /etc/dnf/automatic.conf <<'DNFAUTO'
[commands]
upgrade_type = security
random_sleep = 900
download_updates = yes
apply_updates = yes
[emitters]
emit_via = stdio
DNFAUTO
systemctl enable --now dnf-automatic.timer
echo "==> Kernel/sysctl tuning for L7 proxy"
cat > /etc/sysctl.d/99-traefik.conf <<'SYSCTL'
net.core.somaxconn = 65535
net.core.netdev_max_backlog = 32768
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.ip_local_port_range = 10240 65535
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_keepalive_time = 60
net.ipv4.tcp_slow_start_after_idle = 0
fs.file-max = 2097152
fs.nr_open = 2097152
vm.swappiness = 10
SYSCTL
sysctl --system
cat > /etc/security/limits.d/99-traefik.conf <<'LIMITS'
traefik soft nofile 1048576
traefik hard nofile 1048576
traefik soft nproc 65535
traefik hard nproc 65535
LIMITS
echo "==> Creating traefik user + dirs"
getent passwd traefik >/dev/null || useradd --system --no-create-home --shell /sbin/nologin traefik
mkdir -p /etc/traefik /var/lib/traefik /var/log/traefik
chown -R traefik:traefik /etc/traefik /var/lib/traefik /var/log/traefik
echo "==> Installing Traefik ${TRAEFIK_VERSION}"
ARCH="$(uname -m)"
case "$ARCH" in
x86_64) TRAEFIK_ARCH="amd64" ;;
aarch64) TRAEFIK_ARCH="arm64" ;;
*) echo "Unsupported arch: $ARCH"; exit 1 ;;
esac
TMP="$(mktemp -d)"
cd "$TMP"
curl -fsSLO "https://github.com/traefik/traefik/releases/download/v${TRAEFIK_VERSION}/traefik_v${TRAEFIK_VERSION}_linux_${TRAEFIK_ARCH}.tar.gz"
tar xzf "traefik_v${TRAEFIK_VERSION}_linux_${TRAEFIK_ARCH}.tar.gz"
install -m 0755 traefik /usr/local/bin/traefik
cd /
rm -rf "$TMP"
traefik version
echo "==> Computing first Consul host for KV provider"
PRIMARY_CONSUL="$(echo "$CONSUL_HOSTS" | cut -d, -f1)"
echo "==> Generating dashboard auth hash"
DASHBOARD_HASH="$(htpasswd -nbB "${DASHBOARD_USER}" "${DASHBOARD_PASS}" | sed -e 's/\$/\$\$/g')"
echo "==> Writing static configuration"
cat > /etc/traefik/traefik.yml <<EOF
global:
checkNewVersion: false
sendAnonymousUsage: false
log:
level: INFO
filePath: /var/log/traefik/traefik.log
format: json
accessLog:
filePath: /var/log/traefik/access.log
format: json
bufferingSize: 100
filters:
statusCodes:
- "200-299"
- "300-399"
- "400-599"
retryAttempts: true
minDuration: "10ms"
fields:
headers:
defaultMode: drop
names:
User-Agent: keep
Referer: keep
X-Request-ID: keep
entryPoints:
web:
address: ":80"
http:
redirections:
entryPoint:
to: websecure
scheme: https
permanent: true
websecure:
address: ":443"
http:
tls:
certResolver: lecluster
forwardedHeaders:
trustedIPs:
- 10.30.0.0/16
proxyProtocol:
trustedIPs:
- 10.30.0.0/16
traefik:
address: "127.0.0.1:8080"
metrics:
address: "127.0.0.1:9100"
api:
dashboard: true
insecure: false
ping:
entryPoint: traefik
metrics:
prometheus:
entryPoint: metrics
addServicesLabels: true
addRoutersLabels: true
addEntryPointsLabels: true
buckets:
- 0.001
- 0.01
- 0.05
- 0.1
- 0.25
- 0.5
- 1
- 2.5
- 5
- 10
providers:
consul:
rootKey: "${CONSUL_PREFIX}"
endpoints:
- "${PRIMARY_CONSUL}"
certificatesResolvers:
lecluster:
acme:
email: "${ACME_EMAIL}"
caServer: "${ACME_CASERVER}"
storage: /var/lib/traefik/acme.json
httpChallenge:
entryPoint: web
keyType: EC256
EOF
chown root:traefik /etc/traefik/traefik.yml
chmod 640 /etc/traefik/traefik.yml
touch /var/lib/traefik/acme.json
chown traefik:traefik /var/lib/traefik/acme.json
chmod 600 /var/lib/traefik/acme.json
echo "==> Writing dashboard middleware to Consul (idempotent)"
PRIMARY_HOST="$(echo "$PRIMARY_CONSUL" | cut -d: -f1)"
PRIMARY_PORT="$(echo "$PRIMARY_CONSUL" | cut -d: -f2)"
dashboard_kv_put() {
curl -fsS -X PUT --data-binary "$2" "http://${PRIMARY_HOST}:${PRIMARY_PORT}/v1/kv/$1" >/dev/null
}
dashboard_kv_put "${CONSUL_PREFIX}/http/middlewares/dashboard-auth/basicAuth/users/0" "${DASHBOARD_HASH}"
dashboard_kv_put "${CONSUL_PREFIX}/http/routers/dashboard/rule" "Host(\`traefik.internal\`)"
dashboard_kv_put "${CONSUL_PREFIX}/http/routers/dashboard/entryPoints/0" "websecure"
dashboard_kv_put "${CONSUL_PREFIX}/http/routers/dashboard/service" "api@internal"
dashboard_kv_put "${CONSUL_PREFIX}/http/routers/dashboard/middlewares/0" "dashboard-auth"
dashboard_kv_put "${CONSUL_PREFIX}/http/routers/dashboard/tls/certResolver" "lecluster"
echo "==> Allowing Traefik to bind 80/443 as non-root"
setcap 'cap_net_bind_service=+ep' /usr/local/bin/traefik
echo "==> systemd unit"
cat > /etc/systemd/system/traefik.service <<'UNIT'
[Unit]
Description=Traefik 3 reverse proxy and load balancer
After=network-online.target
Wants=network-online.target
[Service]
Type=notify
User=traefik
Group=traefik
ExecStart=/usr/local/bin/traefik --configfile=/etc/traefik/traefik.yml
Restart=on-failure
RestartSec=2s
LimitNOFILE=1048576
KillMode=mixed
WatchdogSec=15s
NotifyAccess=all
AmbientCapabilities=CAP_NET_BIND_SERVICE
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
NoNewPrivileges=true
ProtectSystem=strict
ReadWritePaths=/var/log/traefik /var/lib/traefik
ProtectHome=true
PrivateTmp=true
[Install]
WantedBy=multi-user.target
UNIT
systemctl daemon-reload
systemctl enable --now traefik
echo "==> Waiting for Traefik to come up"
for i in {1..60}; do
if curl -fs http://127.0.0.1:8080/ping >/dev/null 2>&1; then break; fi
sleep 1
done
echo "==> Installing node_exporter for Prometheus"
NEX_VERSION="1.8.2"
case "$ARCH" in
x86_64) NEX_ARCH="amd64" ;;
aarch64) NEX_ARCH="arm64" ;;
esac
cd /tmp
curl -fsSLO "https://github.com/prometheus/node_exporter/releases/download/v${NEX_VERSION}/node_exporter-${NEX_VERSION}.linux-${NEX_ARCH}.tar.gz"
tar xzf "node_exporter-${NEX_VERSION}.linux-${NEX_ARCH}.tar.gz"
install -m 0755 "node_exporter-${NEX_VERSION}.linux-${NEX_ARCH}/node_exporter" /usr/local/bin/node_exporter
rm -rf "node_exporter-${NEX_VERSION}.linux-${NEX_ARCH}"*
cat > /etc/systemd/system/node_exporter.service <<'NEX'
[Unit]
Description=Prometheus node_exporter
After=network-online.target
[Service]
Type=simple
User=nobody
ExecStart=/usr/local/bin/node_exporter --web.listen-address=127.0.0.1:9101
Restart=on-failure
[Install]
WantedBy=multi-user.target
NEX
systemctl daemon-reload
systemctl enable --now node_exporter
echo
echo "========================================"
echo "DONE"
echo "========================================"
echo
echo "Listeners:"
ss -lntp | grep -E ':(80|443|8080|9100|9101)\b' || true
echo
echo "Traefik version:"
traefik version
echo
echo "Consul KV tree (should contain dashboard router + your routes):"
curl -fsS "http://${PRIMARY_HOST}:${PRIMARY_PORT}/v1/kv/${CONSUL_PREFIX}?recurse&keys" | jq .
echo
echo "Repeat on the other 2 nodes with their NODE_NAME / NODE_IP."
Run on each Traefik node:
chmod 700 /root/setup-traefik-cluster-node.sh
/root/setup-traefik-cluster-node.sh
Once all three are up behind your cloud LB, push application routes into Consul KV under the traefik/ prefix and watch them appear in :8080/api/http/routers on every node within a few seconds. The single-truth pattern: a Git repo holds your declared route set, a CI job applies it to Consul KV (idempotent), and Traefik observes the change. No node is special; rotating one out is systemctl stop traefik and removing it from the LB pool.
Sticky sessions: add loadBalancer/sticky/cookie/name under each service in Consul KV. Cert sharing: the acme.json blob is written by whichever node holds the ACME lock in Consul; the others read it. Confirm the lock holder shifts after systemctl restart traefik on the current holder — if it doesn’t, the resolver isn’t backed by KV and you’ve still got a per-node acme.json situation.
For a Traefik tier you don’t operate yourself — including the Consul KV plane, cert rotation, and Sev-1 monitoring — our environment management team runs the proxy plane end to end. Plan it with us or read about the underlying cloud compute the nodes run on.