Commit 06944c5

Eric Bower  ·  2026-08-10 16:58:05 -0400 EDT
parent 6450bca
fix(caddy): add postgres storage backend for distributed ACME challenges

This updates the Caddy Dockerfile to compile with the
`github.com/yroc92/postgres-storage` module and configures `Caddyfile.pgs` to
use it via the existing `DATABASE_URL` environment variable.

Previously, Caddy instances on independent nodes (e.g., US and EU) used their
own local filesystem for ACME storage. This caused on-demand TLS to hang or time
out for custom domains when Let's Encrypt's ACME verification challenge was
randomly routed by DNS to a node that didn't initiate the request.

By using a central Postgres database for storage, all Caddy nodes now share
certificate state and can seamlessly answer ACME challenges initiated by any
other node in the cluster.
2 files changed,  +5, -1
+3, -0
1@@ -1,4 +1,7 @@
2 {
3+	storage postgres {
4+		connection_string {$DATABASE_URL}
5+	}
6 	on_demand_tls {
7 		ask http://web:3000/check
8 	}
+2, -1
 1@@ -8,7 +8,8 @@ ARG TARGETARCH
 2 ENV GOOS=${TARGETOS} GOARCH=${TARGETARCH}
 3 
 4 RUN xcaddy build \
 5-    --with github.com/caddy-dns/cloudflare
 6+    --with github.com/caddy-dns/cloudflare \
 7+    --with github.com/yroc92/postgres-storage
 8 
 9 FROM caddy:alpine
10