StackExchange / dnscontrol

Infrastructure as code for DNS!
https://dnscontrol.org/
MIT License
3.13k stars 397 forks source link

Cloudflare: "cannot create CNAME record for bare domain" #364

Closed fdcastel closed 6 years ago

fdcastel commented 6 years ago

I'm using dnscontrol 0.1.0 (c52ff67386750e96138fe78f0631d757f928f452) with configurations like

// Providers
var REG_NONE = NewRegistrar('none', 'NONE');
var DNS_CLOUDFLARE = NewDnsProvider('cloudflare.com', 'CLOUDFLAREAPI');

// Meta settings for individual records
var CF_PROXY_OFF = { 'cloudflare_proxy': 'off' };
var CF_PROXY_ON = { 'cloudflare_proxy': 'on' };

// Domains
D('mydomain.com', REG_NONE, DnsProvider(DNS_CLOUDFLARE),
    CNAME('@', 'mywebserver.com.', CF_PROXY_ON),
    CNAME('www', 'mydomain.com.', CF_PROXY_ON)
);

However, upgrading to dnscontrol 0.2.6 ("cea71db3528c5f0af7216dd94d938b28fb1758b7") now give me the error

ERROR: In CNAME @.mydomain.com: cannot create CNAME record for bare domain

While I understand why this check was added, it should not be applied for Cloudflare setups, since CF allows CNAME flattening

https://support.cloudflare.com/hc/en-us/articles/200169056-CNAME-Flattening-RFC-compliant-support-for-CNAME-at-the-root

Or I'm missing something here?

captncraig commented 6 years ago

For bare domains on cloudflare you should use the ALIAS record type. For cloudflare, it uses cnames underneath, but that limits it to providers that implement those similar semantics.

fdcastel commented 6 years ago

Oh! I see.

https://stackexchange.github.io/dnscontrol/alias

Thank you very much, @captncraig. My fault for not RTFM 😉.