Warning
This project is still a work in progress. Do not use in production.
A storage implementation for Caddy / certmagic that uses PostgreSQL as the backend.
- ✅ Supports all Caddy storage operations
- ✅ Directories semantics fully implemented (e.g. listing objects in a directory)
- ✅ Supports storage export (recursive listing of all files)
- ✅ Works in distributed Caddy setups thanks to distributed locking with fencing tokens (pglock)
- ✅ Fully tested (integration tests + smoke tests and real export test)
- ✅ Works with distributed rate limiting (mholt/caddy-ratelimit)
Build the module into your Caddy binary:
xcaddy build --with github.com/dmarcwise/caddy-storage-postgresql
You can pin a specific commit with:
xcaddy build --with github.com/dmarcwise/caddy-storage-postgresql@<commit-hash>
Configure Caddy to use the PostgreSQL storage module. Example Caddyfile
:
{
storage postgresql {
dsn "postgres://user:password@localhost:5432/caddy?sslmode=disable"
}
}
The dsn
parameter is a PostgreSQL connection string, either as a key/value string or as a connection URI.
The sslmode
connection parameter defaults to require
. We recommend setting a statement_timeout
(e.g. 30s
) and other basic parameters.
This module implementation already sets the following connection pooling parameters:
- Maximum open connections:
10
- Maximum idle connections:
3
- Connection maximum idle time:
1h