Skip to content

fix: allow CNAME + other records when Cloudflare proxy is enabled#4189

Open
raman1236 wants to merge 1 commit intoStackExchange:mainfrom
raman1236:fix/cname-cloudflare-proxy-validation
Open

fix: allow CNAME + other records when Cloudflare proxy is enabled#4189
raman1236 wants to merge 1 commit intoStackExchange:mainfrom
raman1236:fix/cname-cloudflare-proxy-validation

Conversation

@raman1236
Copy link
Copy Markdown

Description

Fixes the CNAME + other record type validation to allow coexistence when the CNAME is proxied through Cloudflare (CF_PROXY_ON or CF_PROXY_FULL).

Problem

When using the Cloudflare provider with CF_PROXY_ON, dnscontrol rejects configurations that have a CNAME and another record type (e.g., MX) on the same name:

cannot have CNAME and MX record with same name: mailscanner.example.com

However, when a CNAME is proxied, Cloudflare flattens it internally and returns A/AAAA records to resolvers. The CNAME is never served to the public, so the RFC 1034 §3.6.2 restriction does not apply. Cloudflare itself allows this configuration and it works correctly.

Root Cause

The checkCNAMEs function in pkg/normalize/validate.go unconditionally rejects any record type (except AKAMAICDN) that shares a label with a CNAME, without checking whether the CNAME uses Cloudflare proxy flattening.

Fix

When building the CNAME label map, also track which CNAMEs have cloudflare_proxy metadata set to "on" or "full". Skip the conflict error for those labels, following the same pattern as the existing AKAMAICDN exception.

Tests

Added TestCNAMECloudflareProxied that verifies:

  • Proxied CNAME + MX on the same label produces no error
  • Non-proxied CNAME + MX on the same label still produces an error

Fixes #4181

When a CNAME record has cloudflare_proxy set to 'on' or 'full',
Cloudflare flattens the CNAME internally and returns A/AAAA records
to resolvers. The CNAME is never actually served, so the RFC 1034
§3.6.2 restriction (CNAME must be the only record at a name) does
not apply.

The checkCNAMEs validation now skips the CNAME conflict error for
proxied Cloudflare CNAMEs, similar to the existing AKAMAICDN
exception.

Fixes StackExchange#4181
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CNAME + other record validation should account for Cloudflare proxied (flattened) CNAMEs

2 participants