Overview
Automatic HTTPS is enabled by default when Caddy detects qualifying domain names in your configuration. No additional configuration is required for basic use.Caddy uses CertMagic under the hood—a powerful library for automated certificate management that Caddy’s creator also maintains.
How It Works
Automatic HTTPS operates in two phases:Phase 1: Preparation (During Provisioning)
Fromautohttps.go:71-518, Caddy analyzes the configuration:
1
Extract Qualifying Domains
Caddy scans all server blocks for domain names that qualify for certificates:
autohttps.go:148-168
2
Filter Qualifying Names
Not all names qualify for public certificates:
autohttps.go:202-227
3
Create Automation Policies
Domains are assigned to automation policies based on their characteristics:
autohttps.go:293-339
4
Set Up HTTP→HTTPS Redirects
Automatic redirects are configured for each qualifying domain:
autohttps.go:520-551
Phase 2: Certificate Management (After Server Start)
Fromautohttps.go:800-823, certificates are obtained and managed:
autohttps.go:810-823
Configuration Options
You can control automatic HTTPS behavior per-server:autohttps.go:32-69
Example Configuration
JSON Config
JSON Config
Caddyfile
Caddyfile
Automation Policies
Automation policies control how certificates are obtained and managed:autohttps.go:559-754
Internal Certificate Issuer
For local/internal domains, Caddy uses its internal CA:autohttps.go:690-724
Tailscale Integration
Tailscale domains (*.ts.net) get special handling:autohttps.go:726-745
Certificate Management
The TLS app manages certificates through automation policies:tls.go:547-605
Certificates are obtained asynchronously after servers start. Your sites will be available immediately, with certificates obtained in the background.
ACME Challenges
Caddy supports all ACME challenge types:HTTP-01 Challenge
Caddy automatically handles HTTP challenges:tls.go:667-713
TLS-ALPN-01 Challenge
Handled automatically during TLS handshake.DNS-01 Challenge
Requires DNS provider configuration:Storage and Renewals
Certificates are stored using Caddy’s storage system and automatically renewed:tls.go:812-896
By default, Caddy checks for renewals every 12 hours and renews certificates when they have 30 days or less remaining.
On-Demand TLS
Caddy can obtain certificates on-demand during the TLS handshake:Disabling Automatic HTTPS
Sometimes you need to disable automatic HTTPS:1
Completely Disable
2
Disable Redirects Only
3
Disable Certificates Only
Best Practices
1
Use DNS Challenge for Wildcards
DNS-01 is the only challenge type that supports wildcard certificates.
2
Configure On-Demand Protections
Always use the
ask endpoint or permission module with on-demand TLS.3
Monitor Certificate Renewals
Subscribe to TLS app events to track certificate lifecycle events.
4
Test in Staging First
Use Let’s Encrypt staging for testing to avoid rate limits: