1001Ferramentas
🚀 Dev

Caddyfile Generator

Generate Caddyfile with automatic HTTPS (Let's Encrypt), reverse_proxy or file_server. Modern simple Caddy 2 syntax.

Caddyfile: HTTPS without configuring a certificate

What sets Caddy apart from nginx and Apache is the certificate: point a real domain at the server and it obtains a Let's Encrypt certificate on its own, installs it and renews it, without a single line of configuration for any of that. The config file shrinks in proportion — what takes twenty lines in nginx, with certificate paths and redirects, becomes a three-line block.

Choose the domain and the mode and the page assembles the Caddyfile. In reverse proxy mode the block forwards to the backend address, with the origin headers passed through by default — another difference from nginx, where each of them must be declared by hand. In static file mode it sets the root and turns on the file server. The compression option adds the matching directive.

Two things to know before shipping. Using localhost as the name makes Caddy generate its own certificate, trusted only on that machine, which is excellent for development; with a real domain it attempts Let's Encrypt validation, and for that ports 80 and 443 must be reachable from outside. And the Caddyfile is formatting-sensitive: the opening brace stays on the same line as the address, and directives are indented inside the block.

Frequently asked questions

Do I need port 80 open even serving only HTTPS?
For the most common validation method, yes: Let's Encrypt fetches a file over HTTP before issuing. Port 80 also carries the automatic redirect to HTTPS. The alternative is DNS validation, which drops the port requirement but needs credentials for your DNS provider.
Where are the certificates kept?
In Caddy's data directory, which varies with the installation method — under a systemd service it is usually below /var/lib/caddy. You need not touch them, but it is worth knowing where they are when migrating machines: copying that directory avoids requesting certificates again and hitting the issuance rate limit.
Can I convert my nginx configuration?
Caddy ships an adapter that reads nginx configuration and produces the equivalent, but treat the result as a draft: it covers the common cases and leaves out anything depending on a specific module. For a simple site, writing from scratch usually ends up shorter than converting.

Related Tools