How do I properly convert my old Caddyfile to the new Caddy 2 standard?

1. My Caddy version (caddy -version): 1.0

2. How I run Caddy: Debian 10-based LXC container

a. System environment:

Proxmox server, running in LXC container.

b. Command:

CLOUDFLARE_EMAIL=my_email CLOUDFLARE_API_KEY=random_key caddy -log stdout

d. My complete Caddyfile:

my.domain.com {
proxy / 192.168.1.21:8123 {
  websocket
	transparent
  header_upstream Authorization {>Authorization} 
	}
	tls {
	dns cloudflare
	}
}

second.domain.com {
proxy / 192.168.1.22:5000 {
	transparent
	}
	tls {
	dns cloudflare
	}
}

third.domain.com {
proxy / 192.168.1.23:6888 {
	transparent
	}
	tls {
	dns cloudflare
	}
}

3. The problem I’m having:

I want to start moving over to Caddy 2 but would like to convert this Caddyfile properly, so that it works. The current Caddy 1.0 works fine with the above Caddyfile.

The proxy directive is now reverse_proxy, and websocket and transparent subdirectives aren’t needed anymore, those are now implicit. Also, all headers are forwarded by default now, so you shouldn’t need anything in v2 for the Authorization header to be passed through.

For v2, DNS challenge is supported, but no DNS-challenge-provider plugins have been implemented yet. For now, you could use the HTTP challenge instead, which requires having port 80 open. You’ll need to specify an email. See the tls docs here.

2 Likes

So I can’t really fully use it the way I’m currently using it due to DNS challenge not being supported yet?
Any idea of when that will be implemented?

Any ideas?

I’m not sure if there’s time-frame set for it. We’re currently limited in resources and time. The codebase and the config structure have support for the DNS challenge, but, as @francislavoie said, no DNS-challenge-providers have been implemented and compiled into the codebase yet.

So to use the DNS challenge for duckdns, you will need a Caddy module that accepts the config of this shape:

"challenges": {
        "dns": {
            "provider": "duckdns",
            // whatever the duckdns API requires for the DNS challenge
        }
}

and returns the DuckDNS provider from github.com/go-acme/lego/providers/dns/duckdns.

3 Likes

Am I correct in saying it’s now possible to use Cloudflare DNS challenges in Caddy v2, similar to what I’m currently using in v1? https://github.com/caddyserver/tls.dns

Yup! Use the steps described here to build Caddy v2 from source with the Cloudflare DNS plugin:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.