I moved your post to a new thread so we can address your question.
The first line in your Caddyfile should be the site you want to serve. (Or a global options block, but that’s an exception.)
With your Caddyfile, Caddy is reading that as you wanting to serve sites called tls and myemail@email.com, and within that site you’re trying to configure a directive called dns.
There is no dns directive, though! But there is a directive called tls, and it’s meant to go inside your site configuration.
So what you need to do is take that entire tls section, indent it, put it inside your site configuration, and give that a shot.
That doesn’t look right, though, I’m afraid. You open two brace blocks but never close them:
And, you want Caddy to use the DNS challenge for your wiki subdomain, right?
Start a site config with your site label (i.e. wiki.{$MY_DOMAIN}), open the brace block, then put the whole tls directive inside it, indented. Like, on a new line directly before or after your reverse_proxy.
P.S.: Encase your configs as code blocks - use the preformatted text button up the top or encase them in triple backticks (```) to preserve indentation so it’s easier to read.
Ok. So then like this?
Yes, I do want to use the DNS Challenge for my Wiki. Docker and all containers including Caddy are on one VM and the Wiki is on another VM altogether.
example.com {
}
tls my email address {
dns cloudflare {env.CLOUDFLARE_API_TOKEN}
}
wiki.{$MY_DOMAIN} {
reverse_proxy 192.168.20.10:80
tls my email address
dns cloudflare {env.CLOUDFLARE_API_TOKEN}
}
Sorry, it is still going above my head. I’ve gone through the documentation multiple times. I work better with actual examples, which I can copy and adapt to fit my usecases.
Would be great if you could just format this one correctly, so that I know exactly how it is supposed to look like.