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,4 +1,7 @@
11 {
2+ storage postgres {
3+ connection_string {$DATABASE_URL}
4+ }
25 on_demand_tls {
36 ask http://web:3000/check
47 }
+2, -1
......@@ -8,7 +8,8 @@ ARG TARGETARCH
88 ENV GOOS=${TARGETOS} GOARCH=${TARGETARCH}
99
1010 RUN xcaddy build \
11- --with github.com/caddy-dns/cloudflare
11+ --with github.com/caddy-dns/cloudflare \
12+ --with github.com/yroc92/postgres-storage
1213
1314 FROM caddy:alpine
1415