Caddy HTTPS Redirect Configuration

Caddy's automatic HTTPS handles HTTP-to-HTTPS redirection by default, but you may also need to canonicalise your domain. Generate the correct Caddyfile snippet for both www and non-www redirect rules here.

Automatic by default

For any site block with a public hostname Caddy listens on port 80 and redirects to HTTPS on its own.

www to apex

Redirect the www host to the bare domain with a permanent redirect.

www.example.com {
    redir https://example.com{uri} permanent
}

Open the Reverse proxy generator

Frequently asked questions

Can I turn the automatic redirect off?

Yes, with auto_https disable_redirects in the global options, but it is rarely a good idea.

Guides