First off, congrats to loc.cc on making it onto the PSL 🎉🎉🎉
Over the past few days I’ve seen a bunch of NLers running into problems trying to hook loc.cc up to Cloudflare Pages. The core issue is actually Cloudflare’s external domain validation. I’m putting together the method I use here for reference.
Steps
-
Change the domain’s NS records at Yunamo
First, change the NS addresses for
xxx.loc.ccto the ones provided by AnyNS:ns1.anyns.ioandns2.anyns.ioSetting external NS first is to save time waiting for NS propagation. While that’s happening, we can go add the domain in AnyNS.
-
Add the domain in AnyNS
Go to anyns.io and add the
xxx.loc.ccdomain you just set up. -
Add a custom domain in Cloudflare Pages
I’m assuming you’ve already created the Pages project. Add a custom domain and enter the full
xxx.loc.cc. -
Go back to AnyNS and add a CNAME record
Set the record name to
@, chooseCNAMEas the type, and put your Pages project domain as the value. For root domain handling, you need to choose "Return CNAME directly"; otherwise Cloudflare Pages validation won’t pass and the certificate won’t be issued. -
Wait for Pages to show Active
Once the Pages custom domain status changes to "Active", you can access it via
xxx.loc.cc, and naturally Yunamo’s health checks won’t have any issues either.
How it works
When Cloudflare Pages validates an external domain, it checks whether your authoritative DNS returns the Pages domain it gave you. A lot of DNS providers now enable CNAME flattening by default, so what Cloudflare gets back is a resolved A/AAAA record instead. That makes validation fail and SSL certificate issuance fail. So we need a provider that can host a subdomain, allow a CNAME at the apex, and return the raw CNAME without flattening it.
That said, what we’re doing here is non-standard and comes with two limitations:
-
You can’t enable DNSSEC. If you do, the
CNAMEwill conflict with theSOA / NS / DNSKEYsignatures, and global public DNS resolvers will refuse to resolve it outright. -
It may affect other records at the apex
@. Some resolvers that strictly follow the spec may see theCNAMEand ignore other records at the same level (MX,TXT, etc.). Lower-level subdomains aren’t affected.
Also, after validation passes, don’t turn flattening back on, or certificate renewals may fail later.
That said, if you’re only using it to host Pages, it doesn’t matter. You might be thinking, why not just wait for Cloudflare to merge the PSL and skip all this hassle? Emmm… you probably still have .adc.sd sitting around that needs to be kept alive, right?
首先恭喜 loc.cc 成功加入 PSL 列表🎉🎉🎉
这几天逛论坛发现很多 NLer 在尝试把 loc.cc 接入到 Cloudflare Pages 使用时遇到了问题,核心原因其实是卡在了 Cloudflare 的外部域名校验机制上,我这里把自己用的方法整理出来供大家参考。
操作步骤
-
在 Yunamo 修改域名的 NS 记录
先把
xxx.loc.cc的 NS 地址改为 AnyNS 提供的地址ns1.anyns.io和ns2.anyns.io这里先设置外部 NS 是为了节省等待 NS 生效这段时间,此时我们可以去 AnyNS 添加域名
-
在 AnyNS 中添加域名
前往 anyns.io 把刚刚的
xxx.loc.cc域名添加进去 -
在 Cloudflare Pages 添加自定义域
这里我默认你已经创建好 pages 项目了,添加自定义域,填写完整的
xxx.loc.cc -
回到 AnyNS 添加 CNAME 记录
记录名称填写
@类型选择CNAME,记录值填写你的 pages 项目域名,根域处理方式这里要选择 "直接返回CNAME" 否则 Cloudflare Pages 的验证将无法通过,证书无法下发。 -
等待 Pages 显示活动
等待 Pages 自定义域名的状态变为 "活动" 就可以通过
xxx.loc.cc域名访问了,自然 Yunamo 的健康检查也不会有问题
原理解释
Cloudflare Pages 在验证外部域名的时候,会检查你的权威 DNS 返回的值是不是它给的 pages 域名。现在很多 DNS 服务商会默认开启 CNAME 拉平,这样 Cloudflare 得到的值会是一个解析后的 A/AAAA 记录,就会导致验证失败、无法签发 SSL 证书。所以就需要我们选择一个可以托管二级域名且允许主域名CNAME,还能直接返回原生CNAME不拉平的服务商。
但是我们这里的做法属于非标准的做法,会有两个限制:
-
不能开启 DNSSEC,开启后
CNAME会和SOA / NS / DNSKEY签名产生冲突,导致全球公共 DNS 直接拒绝解析 -
可能会影响主域名
@的其他记录,部分严格遵循协议的解析器可能会看到CNAME后忽略同级的其他记录(MX、TXT等),下级子域名则不会受到影响。
另外,验证通过后也不要重新打开拉平,避免后续证书续签失败。
不过如果只是单纯用来挂 Pages 的话就没影响。你可能会想我直接等 Cloudflare 合并 PSL 不就完了,折腾这些干什么,emmm 你手里应该还有.adc.sd 需要保活吧。
Translated by AI from 简体中文Original (简体中文)
还在为IP不纯、平台风控、频繁验证而烦恼? 丽萨主机海外原生IP VPS,双ISP住宅IP,覆盖美国、香港、日本、新加坡、台湾、德国、越南、英国等热门地区,适合跨境电商、社媒运营、AI工具、流媒体及海外业务使用。
12 replies
Sort order