Overview
By default, Caddy runs over HTTP on your chosen local port. If your deployment requires HTTPS — for example, to encrypt traffic between internal services or to meet security requirements — you can configure Caddy to serve over HTTPS using one of three approaches:- Automatic certificates via a public domain name (using Let’s Encrypt)
- Self-signed certificates for local or internal use
- Custom certificate files provided directly
Automatic HTTPS with a Domain
If you have a public domain name with a DNS record pointing to your server, Caddy can automatically obtain and renew TLS certificates from Let’s Encrypt:proxy.example.com with your actual domain. Caddy will automatically:
- Obtain a TLS certificate from Let’s Encrypt
- Serve HTTPS on port 443
- Redirect HTTP requests to HTTPS
Prerequisite: Your domain must have a valid DNS A record pointing to the server, and port 80 must be publicly accessible so that Let’s Encrypt can complete its HTTP challenge.
Self-Signed Certificate for Internal Use
For internal or local deployments that do not use a public domain, you can instruct Caddy to generate a self-signed certificate using its built-in local certificate authority (CA). This is done by specifyingtls internal in your Caddyfile.
Localhost:
Note: Self-signed certificates will trigger security warnings in browsers and HTTP clients. To suppress these warnings, you must either add Caddy’s local CA certificate to your system’s trusted certificate store, or configure your tools to accept self-signed certificates explicitly.
Custom Certificate Files
If you have your own certificate and private key files, you can specify their paths directly in the Caddyfile:/path/to/cert.pem and /path/to/key.pem with the absolute paths to your
certificate and private key files. If your certificate authority provides intermediate
certificates, use a full-chain certificate file (e.g. fullchain.pem) rather than the
end-entity certificate alone.
Updating Client Configuration for HTTPS
When HTTPS is enabled on your Caddy instance, update the proxy base URL in all client configurations — such as environment variables, configuration files, or SDK settings — to usehttps:// instead of http://.
For example, depending on your deployment, your proxy address will take one of the
following forms: