Multiple domains with cloudflare challenge on different accounts

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?

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.

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

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.

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
}
2 Likes

@frame

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 myemail@gmail.com myglobalapikeywith37chars
	}
}

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

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