主题
域名、DNS 与邮件基础设施系统文档
作用: WellChina 当前生产环境下域名解析、邮件收发、凭证管理的单一事实来源(Single Source of Truth)。新开发者通过此文档即可理解系统全貌。 适用版本: 2026-04-17 起 关联文档:
docs/dns-email-migration-plan.md— 迁移过程的完整操作手册(如何从 0 搭起来)docs/performance-monitoring-plan.md— 全球访问性能与监控
1. 系统总览
┌──────────────────────────────────────────────────────────────────┐
│ │
│ USER LAYER │
│ ├─ 访客浏览器 → HTTPS 访问 wellchina.top │
│ ├─ 陌生发件方 → 邮件投递到 *@wellchina.top │
│ └─ 运营者 Gmail → 阅读转发邮件 + Send As 回信 │
│ │
│ ─────────────────────────────────────────────────────────────── │
│ │
│ DNS / 路由层 │
│ ├─ Namesilo → 域名产权登记(只有续费用途) │
│ └─ Cloudflare → DNS 权威解析 + Email Routing 收件转发 │
│ (当前所有记录灰云 / DNS Only) │
│ │
│ ─────────────────────────────────────────────────────────────── │
│ │
│ 应用层 │
│ ├─ Vercel → Next.js 生产部署(edge: 新加坡 / 东京) │
│ ├─ Supabase → PostgreSQL + Auth + Storage (ap-ne-1) │
│ └─ Resend → 邮件发送 SMTP 集群 (ap-northeast-1) │
│ │
└──────────────────────────────────────────────────────────────────┘2. 组件职责 & 费用
| 组件 | 角色 | 账号 / 项目 | 年费 |
|---|---|---|---|
| Namesilo | 域名注册商(产权登记) | wellchina.top | ~¥20 |
| Cloudflare | DNS 权威 + Email Routing + 未来 CDN/WAF | Free plan | $0 |
| Resend | 邮件发送(SMTP + REST API) | Tokyo region | $0(3k/月内) |
| Gmail | 读写邮件界面(+ Send As 代发身份) | 运营者个人号 | $0 |
| Vercel | Next.js 部署 | Hobby plan | $0 |
| Supabase | 数据库 + Auth + Storage | hsmxrctokwgdxauhirec | $0 |
全栈年成本 ≈ 20 元人民币(仅域名续费)。
3. DNS 记录清单(生产现状)
所有记录在 Cloudflare 管理。下表是完整 zone 状态。
网站 / 应用
| Type | Name | Value | Proxy | 作用 |
|---|---|---|---|---|
| A | wellchina.top | 216.198.79.1 | 🔘 灰云 | Vercel apex(307 → www;canonical 为 www) |
| CNAME | www | 6fad2b69a69b422b.vercel-dns-017.com | 🔘 灰云 | Vercel www(200 OK,canonical / schema / sitemap / hreflang 全部指向此) |
邮件 — 收件(Cloudflare Email Routing)
| Type | Name | Value | Priority | 作用 |
|---|---|---|---|---|
| MX | wellchina.top | route1.mx.cloudflare.net | 79 | Primary MX |
| MX | wellchina.top | route2.mx.cloudflare.net | 89 | Secondary |
| MX | wellchina.top | route3.mx.cloudflare.net | 87 | Tertiary |
| TXT | wellchina.top | v=spf1 include:_spf.mx.cloudflare.net ~all | — | Cloudflare SPF(根域) |
| TXT | cf2024-1._domainkey | v=DKIM1; h=sha256; k=rsa; p=... | — | Cloudflare DKIM |
邮件 — 发件(Resend)
| Type | Name | Value | 作用 |
|---|---|---|---|
| MX | send | feedback-smtp.ap-northeast-1.amazonses.com (priority 10) | Resend 退信域 |
| TXT | send | v=spf1 include:amazonses.com ~all | Resend SPF(子域,不与根域冲突) |
| TXT | resend._domainkey | p=MIGfMA0GCSqGSIb3D... | Resend DKIM |
邮件 — DMARC 策略
| Type | Name | Value | 作用 |
|---|---|---|---|
| TXT | _dmarc | v=DMARC1; p=none; rua=mailto:dmarc@wellchina.top; pct=100; | 观察模式,聚合报告进 Gmail |
DMARC 策略演进
当前 p=none(观察期)。演进路径:
| 阶段 | 策略 | 触发条件 |
|---|---|---|
| 当前 | p=none | 刚部署,收集数据 2-4 周 |
| 下一步 | p=quarantine | 2-4 周报告显示合法邮件 100% DMARC pass |
| 终态 | p=reject | quarantine 稳定 4 周后升级 |
4. 目标邮箱地址表
| 地址 | 方向 | 终点 | 当前路由状态 |
|---|---|---|---|
hello@wellchina.top | 收 | 运营者 Gmail(Cloudflare 转发) | ✅ Active |
support@wellchina.top | 收 | 运营者 Gmail | ✅ Active |
dmarc@wellchina.top | 收 | 运营者 Gmail(收 DMARC 报告) | ✅ Active |
no-reply@wellchina.top | 发 | Resend 代发(没人能回信) | ✅ Active |
*@wellchina.top Catch-all | — | Disabled | 防垃圾,按需启用 |
5. 邮件流(收发路径图解)
5.1 出站(系统通知类邮件)
Next.js API / Supabase Auth
↓ 调用
Resend REST API / SMTP
(smtp.resend.com:465)
↓ 发送
Amazon SES (Tokyo)
↓ 投递
收件人邮件服务器
↓ 验证
├─ SPF: send.wellchina.top → pass ✅
├─ DKIM: resend._domainkey → pass ✅
└─ DMARC: relaxed align → pass ✅发件人显示:WellChina <no-reply@wellchina.top>Return-Path:bounce@send.wellchina.top(Resend 退信域)
5.2 入站(外部人发给 hello@/support@)
外部发件方
↓ 查 wellchina.top MX 记录
Cloudflare MX (route1/2/3.mx.cloudflare.net)
↓ 收到邮件,查 Email Routing 规则
匹配 "hello@" / "support@" / "dmarc@"
↓ 转发到配置好的目标
运营者 Gmail 收件箱能看到的元数据:
- Gmail headers → Received-From: route*.mx.cloudflare.net
- SPF/DKIM/ARC/Spam 状态在 Cloudflare Activity log 里可查
5.3 Send As(运营者在 Gmail 里以 hello@ 身份回信)
Gmail 写新邮件
From: WellChina <hello@wellchina.top>
↓ 经由 Gmail 配置的 SMTP
smtp.resend.com:465 (auth: resend / API key)
↓ 发送(使用 wellchina.top 的 DKIM 签名)
收件人邮件服务器对收件人而言,邮件来源看不出 Gmail 的影子——完整呈现 hello@wellchina.top 身份。
5.4 Supabase Auth(注册验证、密码重置等)
Supabase Auth 触发事件
(user signup / password reset / magic link)
↓ 配置了 Custom SMTP
smtp.resend.com:465
↓ 以 no-reply@wellchina.top 发出
用户邮箱Supabase Dashboard → Authentication → Emails → SMTP Settings 配置位置。
6. 凭证清单
| 凭证 | 存储位置 | 用于 | 轮换频率 |
|---|---|---|---|
Resend API Key (re_xxx) | Vercel env RESEND_API_KEY | 代码中 Resend 调用 | 有泄露风险时立即 |
本地 .env(已 git 追踪) | 本地开发 | 同步 | |
Gmail Send As SMTP password(hello@ 和 support@) | Send As 代发 | 同步 | |
| Supabase Dashboard → Auth → SMTP password | Auth 邮件 | 同步 | |
| Supabase Service Role Key | Vercel env + .env | 服务端 Supabase 操作 | 季度轮换 |
| Database URL + password | Vercel env + .env | Prisma 数据库连接 | Supabase 侧轮换时同步 |
| Cloudflare Account | 账号邮箱 + 2FA | DNS / Email Routing 管理 | — |
| Gmail Account | 账号邮箱 + 2FA | 读写邮件 | — |
| Namesilo Account | 账号邮箱 | 域名续费 | — |
轮换 Resend API Key 的标准流程
- Resend Dashboard → API Keys → Create 新 key
- 同步更新 4 处(顺序随意但全部要更新):
- Vercel 生产 env
RESEND_API_KEY→ 触发 redeploy - 本地
.envRESEND_API_KEY→ 重启 dev server - Gmail Settings → Accounts → Send mail as →
hello@和support@各编辑 SMTP password - Supabase Dashboard → Auth → Emails → SMTP Settings → 更新 password
- Vercel 生产 env
- 都确认生效后 Resend Dashboard revoke 旧 key
- 发一封测试邮件验证链路
7. 日常运维操作
加一个新邮箱地址(如 billing@wellchina.top)
- Cloudflare →
wellchina.top→ Email → Email Routing → Routes → Create address - Custom address:
billing@wellchina.top - Action: Send to → 选已验证的 Destination(运营者 Gmail)
- Save,立即生效
- (可选)Gmail → Settings → Accounts → Send mail as → 加
billing@wellchina.top(SMTP 同 Resend)
加一个 DNS 记录(例如外部服务验证)
- Cloudflare →
wellchina.top→ DNS → Records → Add record - 邮件相关记录永远用灰云(DNS Only),非邮件记录视情况
配新服务的环境变量
- Vercel → Settings → Environment Variables(Production)
NEXT_PUBLIC_*变量是 build-time baked,加完必须 redeploy- 其他服务端变量 runtime 生效,redeploy 也不会坏事
网站紧急宕机处理
- 访问 https://check-host.net 确认是否全球不通(排除本地 DNS 劫持)
- Vercel Dashboard → Deployments → 最近 build 是否 Failed
- Cloudflare → DNS → 核对 A + CNAME 记录没被误删
- 如果 Cloudflare 橙云把流量搞坏,切灰云:
- DNS 页面找 A 记录,点 Proxy status 开关切成 DNS Only
- 实在搞不定,Vercel Dashboard → Deployments → Previous → Promote to Production 回滚
8. 监控与健康检查
定期查看的三个 Dashboard
| Dashboard | 频率 | 关注指标 |
|---|---|---|
| Resend → Logs | 每周 | 发送成功率、退信率(< 2%) |
| Cloudflare → Email Routing → Activity | 有异常时 | SPF/DKIM/Spam 状态,转发是否失败 |
| Google Postmaster Tools | 每 2 周 | Gmail 用户对 wellchina.top 的投递分类 |
每日 DMARC 报告(已订阅)
- 发件人: 各大邮件服务商(Gmail / Yahoo / Outlook...)
- 收件地址:
dmarc@wellchina.top - 内容: 每日 XML,统计过去 24h 的 DMARC 对齐情况
- 阅读建议: 前 2 周积累数据后再看,用 dmarc.postmarkapp.com 等工具可视化
命令行健康检查
以下命令必须用 DoH 绕过本地 DNS 劫持(国内运营商常劫持):
bash
# 查 apex A 记录
curl -s "https://cloudflare-dns.com/dns-query?name=wellchina.top&type=A" \
-H "accept: application/dns-json" | jq
# 查所有 TXT(SPF + DKIM + 验证类)
curl -s "https://cloudflare-dns.com/dns-query?name=wellchina.top&type=TXT" \
-H "accept: application/dns-json" | jq '.Answer[].data'
# 查 MX 记录
curl -s "https://cloudflare-dns.com/dns-query?name=wellchina.top&type=MX" \
-H "accept: application/dns-json" | jq '.Answer[].data'
# 查 DMARC 策略
curl -s "https://cloudflare-dns.com/dns-query?name=_dmarc.wellchina.top&type=TXT" \
-H "accept: application/dns-json" | jq9. 故障排查速查表
| 症状 | 最可能原因 | 定位步骤 |
|---|---|---|
| 访问 wellchina.top 显示 Vercel 占位页 | www 的 CNAME 还没 verified | Vercel Domains 页 Refresh,或等 DNS 传播 |
| 访问返回 525/526 SSL 错误 | Cloudflare 代理状态是橙云,Vercel SSL 冲突 | DNS 页面把 A/CNAME 切灰云 |
| 发邮件进收件人垃圾箱 | 新域/.top 低信誉 | 让对方标 "Not spam",等积累;2-4 周后升级 DMARC 到 quarantine |
| Supabase 不发验证邮件 | SMTP 密码填错或 API key 过期 | Supabase Dashboard → Auth → Emails → 发一封 test |
| Gmail Send As 验证链接收不到 | Cloudflare Email Routing 的 hello@ 规则未启用 | Cloudflare → Email Routing → Routes 检查 |
| DMARC 报告发不过来 | dmarc@ 转发规则没配 | Cloudflare → Email Routing → Routes 加一条 |
| 联系表单提交 201 但没邮件 | 本地 dev .env 缺 RESEND_API_KEY | 日志里看 RESEND_API_KEY not configured |
| 中国大陆访问慢 | Vercel 无国内节点,结构性问题 | 启用 Cloudflare 橙云(需配 SSL Full Strict)或用阿里云 DCDN |
.env 变更后 dev server 行为没变 | NEXT_PUBLIC_* 需 restart | lsof -ti:3017 | xargs kill 后重启 dev server |
10. 未来演进路线
近期(1-3 个月)
- DMARC 从
p=none→p=quarantine→p=reject - 注册 Google Postmaster Tools 拿真实投递反馈
- 考虑启用 Cloudflare 橙云改善中国访问(需配 SSL Full Strict)
中期(3-6 个月)
- 邮件模板多语言化(当前英文)—— 利用 Supabase Auth 模板的 locale 变量
- 联系表单邮件加
List-Unsubscribe头(营销类邮件合规) - 加 BIMI 记录展示品牌 logo(需要 VMC 证书,~$1k/年,非急需)
长期(6 个月后,业务成熟)
- 考虑迁到
.com品牌域名 ——.topTLD 结构性信誉低于.com,哪怕 SPF/DKIM/DMARC 全绿,垃圾箱倾向无法彻底消除 - 如果选择迁移,流程大致是:注册新 .com → Cloudflare 加一个 zone → Resend + Email Routing 加新域 → Vercel 加新域 → 301 redirect 旧域 →
FROM_EMAIL等配置切换。旧wellchina.top至少保留 1-2 年做跳转。
11. 关键决策记录(Architecture Decision Records)
ADR-1:DNS 托管选 Cloudflare 而非留 Namesilo
- 决策时间: 2026-04-17
- 原因: Namesilo 无免费邮件转发;Cloudflare 提供免费 Email Routing + 未来可切换 CDN/WAF
- 代价: 多一次 nameserver 切换,DNS 管理从 Namesilo 移到 Cloudflare
ADR-2:所有 DNS 记录保持灰云(DNS Only),不启用橙云代理
- 决策时间: 2026-04-17
- 原因: Vercel 自带 CDN + SSL 管理,橙云代理会产生 SSL 双证书、缓存冲突等问题
- 触发切换条件: 中国大陆 p75 LCP > 2.5s 且业务稳定,才考虑走橙云
ADR-3:发送用 Resend、接收用 Cloudflare Email Routing,不用 Zoho/Google Workspace
- 决策时间: 2026-04-17
- 原因: Resend 代码集成友好、Cloudflare 免费且 UI 现代;Zoho 免费但投递率略逊、Google Workspace 付费过早
- 代价: 邮件读写依赖 Gmail Send As,若 Gmail 账号出问题影响运营
ADR-4:NEXT_PUBLIC_SITE_URL 统一,删除 NEXT_PUBLIC_BASE_URL
- 决策时间: 2026-04-17
- 原因: 原代码有两个含义相同的 env var,归一化降低维护成本
- 迁移:
src/lib/email.ts里NEXT_PUBLIC_BASE_URL引用已改成NEXT_PUBLIC_SITE_URL
ADR-5:.env 纳入 git 版本控制(私有仓库)
- 决策时间: 2026-04-17
- 原因: 当前是私有仓库,只有 owner 使用,便于新机器快速起步;
.env.local保留 gitignore 作为本地覆盖机制 - 风险: 仓库公开或引入协作者前必须 rotate 所有凭证 + 恢复
.env*gitignore
ADR-6:canonical 从 apex 切到 www(https://www.wellchina.top)
- 决策时间: 2026-04-26
- 背景: Vercel 默认把 apex
wellchina.top307 redirect 到www.wellchina.top;原NEXT_PUBLIC_SITE_URL=https://wellchina.top导致所有 schema / sitemap / hreflang / llms.txt / OG URL 指向 apex,而 apex 不返回 200 - 触发: GSC URL Inspection 报
pageFetchState: REDIRECT_ERROR——Google 抓取 8 个 locale URL 全部失败索引 - 决策:
NEXT_PUBLIC_SITE_URL改为https://www.wellchina.top,让 canonical 与实际返回 200 的 URL 对齐;保留 Vercel 默认 apex→www 307 行为不动 - 影响范围: 重新部署后 build-time 烘焙的 BASE_URL 全量更新(schema、sitemap、hreflang、llms.txt、邮件模板、OG);GSC 重提交 8 个 www URL
- 代价: 用户输入
wellchina.top仍然能到,多一跳 307 不影响 UX;search 索引以 www 为准
12. 相关文档 & 外部资源
仓库内
docs/dns-email-migration-plan.md— 迁移 Phase 1-7 完整操作步骤docs/performance-monitoring-plan.md— 全球访问性能监控CLAUDE.md— 项目环境变量简表.env.example— 环境变量模板