Multiple domains with cloudflare challenge on different accounts

(z) #1

Hi, I’m reading the doc but I don’t find much about that… for DNS challenge with cloudflare I need to set two env vars, containing the mail and apikey, but what if I have two domains linked to two different cloudflare accoutns? How should I set the env variables?

(Matthew Fay) #2

Hi @frame,

Assigning env vars is, naturally, a procedure specific to the environment you run Caddy in.

Generally speaking, the Wikipedia page has some basic syntax to achieve this for the different major operating systems.

(z) #3

Hi @whitestrake, thanks for the explaination but that’s not the issue. the problem is that the cloudflare plugin is looking for 2 env vars (mail and api token), if I use one domain it’s all fine, but if I want to use two domains on two different cloudflare accounts I will have 2 mails and 2 token, that ofcourse, can’t be both on the same env variable

(Matthew Fay) #4

Whoops, just realised that, looks like I was a bit quick off the mark… Sorry.

The same environment can’t have the same env vars set differently, and Caddy doesn’t have a method to pick up multiple TLS credentials for the same provider and differentiate them across domains. The closest it can get is to have credentials for multiple separate DNS providers.

(z) #5

Ok i found the solution reading the plugin source (since is not documented)

you can manually set the credentials using as first argument of the call the email and as second argument the apikey so it will be

tls {
  dns cloudflare my@email.tld abcdefghiapikehere

(Eduardo Perroud) #6


I have tried to use it, but doesn’t work properly. I got the message status:

2018/10/30 09:21:58 /etc/caddy/Caddyfile:107 - Error during parsing: Wrong argument count or unexpected line ending after 'myglobalapikeywith37chars'

The code that I did into Caddyfile:

(tls-cf-pp) {
	tls {
		dns cloudflare myglobalapikeywith37chars

What I’m doing wrong? Can you help me?