admin.config.load, module http) asks DNZ for
its configuration every 10 seconds, and Caddy gets its certificates itself.
Caddy 2.7 or newer is needed (weighted round robin). Turn proxying on first, under
Settings → Proxy. See Turning proxying on.
Setting it up
1
Open the setup guide
Go to Settings → Proxy → Add proxy and pick Caddy. Give the name and the addresses
visitors reach it at. Everything in the setup is filled in, ready to copy as it is: New Caddy
(Docker), Installed Caddy (systemd) or Just the file.
2
Check DNZ's address
DNZ address, as Caddy reaches it is filled in from your browser. Change it when Caddy reaches
DNZ another way.A
localhost address only works for a Caddy on the same machine. For one elsewhere, use DNZ’s
LAN or public address and start DNZ with DNZ_HTTP_ADDR=0.0.0.0:8080, or put DNZ behind a
reverse proxy. See HTTPS.3
Start Caddy from dnz.json
Pick one of the ways below. Open ports 80 and 443 (and 443/udp for HTTP/3) to visitors.
4
Let it connect
A Caddy that calls from the addresses you gave connects as that proxy. From anywhere else, it
shows up on the Proxy page as detected, to approve. See
How DNZ recognizes a Caddy.
dnz.json, with the server’s connect key:
dnz.json
GET /api/proxy/caddy 10 seconds (load_delay) after each load. Each configuration
DNZ sends names the loader again, so Caddy keeps asking.
- New Caddy (Docker)
- Installed Caddy (systemd)
- Just the file
Put The setup guide’s one command writes both files to
dnz.json next to this file and run docker compose up -d:docker-compose.yml
~/caddy and starts Caddy.How DNZ recognizes a Caddy
A Caddy is recognized and approved exactly like a Traefik:- by the address it calls from: one of the proxy’s addresses, or its Calls DNZ from;
- a Caddy from any other address shows up on the Proxy page as detected and waits until you approve, link or ignore it;
- several Caddies behind one address give each a name on the URL:
http://DNZ-ADDRESS:8080/api/proxy/caddy?name=edge-1; - a proxy can get a token of its own (⋯ → Use a token of its own), which then goes in the
Authorizationheader instead of the connect key.
What Caddy gets
DNZ translates the proxy’s routers, services and middlewares into Caddy’s own JSON configuration.- HTTPS routers go to a Caddy server on
:443, where Caddy gets the certificates itself (automatic HTTPS, Let’s Encrypt or ZeroSSL). A router’s certificate resolver isn’t used. - Certificates uploaded to the proxy (TLS → Certificates) are loaded into Caddy.
- Wildcard hosts need Caddy built with a DNS provider module, or an uploaded certificate.
- Other routers go to a server on
:80, which also answers Caddy’s HTTP-01 challenges. - Caddy’s own HTTP→HTTPS redirects are off. An HTTP router with a redirect middleware does that, as with Traefik; Add route makes both in one step.
- The entry points of a Caddy proxy are
web(:80) andwebsecure(:443). - Order: exact hosts before wildcards, longer path prefixes first, and a set priority before all of it. A request no route takes gets a 404.
Left out
These are left out, with a warning on the proxy’s page:Trying the endpoint by hand
Run this from the Caddy’s machine, so DNZ recognizes it by that address:GET /api/proxies/{id}/caddy or dnz proxy caddy <proxy>. See the
Proxy API.
Troubleshooting
The proxy's dot stays grey (not connected)
The proxy's dot stays grey (not connected)
The Caddy hasn’t fetched its configuration in the last minute. Check that it started from
dnz.json (not the Caddyfile), that it can reach DNZ’s HTTP address (a localhost address only
works on the same machine), that the file has the current connect key, and look on the Proxy
page for a detected Caddy: it may be calling from an address DNZ doesn’t know yet.My Caddyfile sites are gone
My Caddyfile sites are gone
DNZ’s configuration replaces the Caddy’s whole configuration. Move those sites into routers on
the proxy’s page, or keep the Caddyfile and use Caddy sites in DNS
instead.
A wildcard host has no certificate
A wildcard host has no certificate
Caddy needs a DNS challenge for a wildcard certificate, so it must be built with a DNS provider
module. Otherwise, upload the certificate to the proxy under TLS → Certificates.
A router or middleware doesn't do anything
A router or middleware doesn't do anything
It may be one Caddy can’t take. The proxy’s page lists what was left out, and why.
Next steps
Routers, services and middlewares
Set up what each Caddy serves.
Caddy sites in DNS
Keep your Caddyfile and only get DNS records for its sites.