AutomationConfig
The top-level automation configuration controls certificate management policies and intervals.List of automation policies. The first policy matching a certificate or subject name will be applied.Each policy can specify which subjects it applies to and which issuers to use for certificate management.
On-Demand TLS configuration. Defers certificate operations to the moment they are needed (during TLS handshake).
Caddy was the first web server to implement this experimental technology in 2015.
How often to scan OCSP responses for freshness and update them if getting stale.Caddy staples OCSP and caches the response for all qualifying certificates by default.
How frequently to scan all loaded, managed certificates for expiration.
How often to scan storage units for old or expired assets and remove them.Storage is always cleaned when the process first starts. A new cleaning starts this duration after the previous one started, but only if the previous cleaning finished in less than half this interval.
These scans exert lots of reads and list operations on storage. Choose a longer interval for large deployments.
Automation Policy
An automation policy designates how to automate the management (obtaining, renewal, and revocation) of TLS certificates.Policy Configuration
Which subjects (hostnames or IP addresses) this policy applies to.
This is a filter, not a command. It’s used only to determine whether this policy should apply to a subject that needs a certificate. To have Caddy automate certificates for specific subjects, use the “automate” certificate loader module.
Modules that may issue certificates.Default:
internal if all subjects do not qualify for public certificates; otherwise acme and zerossl.Available issuers:acme- ACME protocol (Let’s Encrypt, ZeroSSL, etc.)zerossl- ZeroSSL API (distinct from ACME)internal- Internal CA using PKI app
Modules that can get a custom certificate for any given TLS handshake at handshake-time.Enables on-demand TLS as a side-effect. Useful when another entity is managing certificates and Caddy only needs to retrieve and serve them.
If true, certificates will be requested with MustStaple.
How long before expiration to try renewing a certificate, as a function of its total lifetime.
As a conservative rule, it’s good to renew when about 1/3 of lifetime remains. This uses the majority of the certificate’s lifetime while saving time to troubleshoot. For extremely short-lived certs, you may want to increase to ~0.5.
The type of key to generate for certificates.Supported values:
ed25519p256p384rsa2048rsa4096
Optionally configure a separate storage module associated with this policy, instead of using Caddy’s global/default-configured storage.
If true, certificates will be managed “on demand” - during TLS handshakes or when needed, rather than at startup or config load.This enables On-Demand TLS for this policy.
If true, private keys already existing in storage will be reused.Otherwise, a new key will be created for every new certificate to mitigate pinning and reduce the scope of key compromise.
Disables OCSP stapling.
EXPERIMENTAL: Subject to change.
Overrides the URLs of OCSP responders embedded in certificates.Each key is an OCSP server URL to override, and its value is the replacement. An empty value disables querying of that server.
EXPERIMENTAL: Subject to change.
Configuration Examples
Basic Automation Policy
On-Demand TLS with Permission Module
Custom Renewal and Storage Settings
Internal CA for Development
Default Issuers
When no issuers are explicitly configured, Caddy uses sensible defaults:-
For public certificates (domains qualifying for public trust):
- ACME issuer (Let’s Encrypt)
- ZeroSSL ACME issuer (if email is provided)
-
For internal certificates (localhost, .local, IP addresses):
- Internal issuer using Caddy’s PKI app
On-Demand TLS
On-Demand TLS allows Caddy to obtain certificates during the TLS handshake, when the certificate is first needed.Permission Module
The permission module (typicallyhttp) makes a request to your application to determine if a certificate should be allowed:
Full URL to the permission endpoint. A query parameter
?domain=example.com will be added.The endpoint must return HTTP 200 OK to allow the certificate; anything else denies it. Redirects are not followed.Example Permission Endpoint
Caddyfile Configuration
Best Practices
Renewal Window: The default 1/3 lifetime ratio means a 90-day Let’s Encrypt certificate renews around 30 days before expiration, leaving ample time for troubleshooting.
Key Types: Ed25519 offers the best performance and security for most use cases. RSA keys are larger and slower but may be required for compatibility with older clients.