Cloudflare DNS And HTTPS For Personal Services
guide2026-06-0210 min read
Use one domain as the control plane for VPS services, Vercel projects, HTTPS certificates, and public-safe documentation.
cloudflarednscaddyhttps
Summary
把个人 AI 基础设施跑起来以后,真正难维护的不是单个服务,而是入口层:哪个子域名指向 VPS,哪个交给 Vercel,什么时候用 Cloudflare 橙云代理,什么时候必须保持灰云,Caddy 如何自动申请证书,出问题时应该先查 DNS 还是先查应用。 这篇笔记把这些问题收成一条统一流程。它适合管理blog.example.com、langflow.example.com、search.example.com、panel.example.com 这类个人服务入口,同时避免在公开教程里泄露真实域名、IP、订阅路径和内部服务名。
What This Solves
当个人项目变多以后,域名会很快失控:- 博客在 Vercel 上,服务在 VPS 上。
- LangFlow、search、admin panel、API 都想用独立子域名。
- 有些服务应该走 Cloudflare 代理,有些服务不能走代理。
- Caddy 需要通过公网验证域名所有权并申请证书。
- 公开教程又不能写真实域名、源站 IP、API key 或私有路径。
Cloudflare 管 DNS,Caddy 管 VPS 上的 HTTPS 和反向代理,Vercel 管托管项目的构建和部署。不要把这三件事混在一起排查。
Who This Is For
这篇文章适合已经有一个域名、一台 VPS、一个或多个 Vercel 项目,并且想把个人 AI 工具统一放到子域名下面的人。 它不假设你已经很熟 DNS,但你需要能:- 登录 Cloudflare 控制台。
- 登录域名注册商后台改 nameserver。
- SSH 到 VPS。
- 编辑 Caddyfile。
- 在 Vercel 项目里添加 custom domain。
Prerequisites
- 一个已经购买的域名,例如
example.com。 - 一个 Cloudflare 账号。
- 一台 VPS 的公网 IP,例如
203.0.113.10。 - VPS 上开放
80和443,并允许 Caddy 监听。 - 一个 Vercel 项目,如果你要部署博客或前端站点。
- 本地工具:
dig、curl、systemctl。
The Workflow
把域名的权威 DNS 交给 Cloudflare
在 Cloudflare 添加根域名,例如
example.com。Cloudflare 会给出两条 nameserver。然后到域名注册商后台,把原 nameserver 替换成 Cloudflare 提供的两条。等待生效后,Cloudflare DNS 页面就成为这个域名的主要控制面。以后新增服务入口、迁移 VPS IP、绑定 Vercel 域名,优先从这里看。先画出服务入口表
不要边配边猜。先写一张表,决定每个子域名归谁处理。
这张表能防止一个常见错误:域名已经指向 Vercel,却还在 VPS 的 Caddyfile 里排查;或者 Cloudflare 开了代理,却在非 HTTP 端口上测试。
| Hostname | Target | DNS Record | Proxy Status | Owner |
|---|---|---|---|---|
blog.example.com | Vercel | CNAME / Vercel suggested record | Usually DNS only or per Vercel guidance | Vercel |
langflow.example.com | VPS Caddy | A -> 203.0.113.10 | Start DNS only, then decide | Caddy |
search.example.com | VPS Caddy | A -> 203.0.113.10 | Start DNS only, then decide | Caddy |
panel.example.com | VPS Caddy | A -> 203.0.113.10 | DNS only while issuing cert | Caddy |
ssh.example.com | VPS SSH | A -> 203.0.113.10 | DNS only | SSH |
给 VPS 服务添加 A 记录
VPS 上由 Caddy 接管的服务,通常用 A 记录指向 VPS 公网 IP:这会创建
langflow.example.com。如果多个服务都在同一台 VPS 上,继续添加 search、panel、api 等子域名,Content 都可以先指向同一个 VPS IP。用 Caddy 接住 VPS 上的 HTTPS
在 VPS 上让 Caddy 把不同子域名转发到不同本地端口:保存后重载:Caddy 会为这些域名处理 HTTPS。前提是公网可以访问 VPS 的
80 和 443,并且 DNS 已经指向正确入口。理解灰云和橙云
Cloudflare 的
DNS only 是灰云:Cloudflare 只返回 DNS 解析结果,流量直接去源站。Proxied 是橙云:HTTP/HTTPS 流量会经过 Cloudflare 网络,再转发到源站。实用规则:| Situation | Recommended Status |
|---|---|
| Caddy 首次申请 Let’s Encrypt 证书 | 先用 DNS only |
| SSH、数据库、邮件、非 HTTP 服务 | DNS only |
| 普通网站或 API,端口受 Cloudflare 支持 | 可以 Proxied |
| Vercel custom domain | 按 Vercel 提示配置,不要和 VPS 记录冲突 |
| 需要直接看到源站 IP 的调试 | DNS only |
给 Vercel 项目绑定域名
Vercel 项目的域名不要指向 VPS。进入 Vercel Project Settings -> Domains,添加 如果这个域名已经有指向 VPS 的 A 记录,先删掉或改掉冲突记录。一个 hostname 不应该同时被两个平台争抢。
blog.example.com 或你要使用的域名,然后按 Vercel 给出的 DNS 记录在 Cloudflare 添加。常见形态是 CNAME 或 A 记录,具体以 Vercel 当前提示为准:Proxy And HTTPS Decision Table
| Layer | What It Controls | Common Symptom | Where To Debug |
|---|---|---|---|
| Registrar nameserver | Who controls DNS | Cloudflare records seem ignored | Registrar dashboard |
| Cloudflare DNS record | Hostname -> target | Domain resolves to wrong place | Cloudflare DNS page, dig |
| Cloudflare proxy status | Direct origin vs Cloudflare edge | Works on gray cloud, fails on orange cloud | Proxy status, supported ports, SSL/TLS mode |
| Caddy | HTTPS and reverse proxy on VPS | Domain reaches server but app does not load | Caddyfile, Caddy logs |
| App service | Local app process | Caddy returns 502 or empty response | Local port, Docker logs, health check |
| Vercel | Build and hosted frontend | Custom domain opens old or wrong project | Vercel Domains, Git branch, production deployment |
SSL/TLS Rules
Cloudflare has two TLS connections to think about:- origin has a valid certificate, usually from Caddy or the hosting provider;
- Cloudflare SSL/TLS mode uses Full or Full strict when proxying;
- avoid Flexible for services that already support HTTPS, because it can hide origin-side HTTP problems and cause redirect loops.
Common Failure Modes
Public Tutorial Hygiene
Use this replacement table before publishing any deployment note:| Private Value | Public Replacement |
|---|---|
| Real domain | example.com, langflow.example.com, blog.example.com |
| Real VPS IP | 203.0.113.10 |
| API key | $LANGFLOW_API_KEY, $OPENAI_API_KEY |
| Flow ID or project ID | $FLOW_ID, $PROJECT_ID |
| Admin path | /private-login-path/ |
| Subscription link | https://panel.example.com/sub/private-token |
| WebSocket path | /ws-private-path |
Reference Notes
The operational rules above line up with these official references:- Cloudflare Proxy status explains the difference between proxied records and DNS-only records.
- Cloudflare Full strict mode documents the stricter origin certificate requirement.
- Caddy reverse_proxy documents the directive used to forward requests to upstream services.
- Caddy Automatic HTTPS documents how Caddy automates certificate management for public hostnames.
Final Checklist
- The registrar nameservers point to Cloudflare.
- Every public hostname has exactly one intended owner: Vercel, VPS Caddy, or another provider.
- VPS service hostnames have A records pointing to the VPS IP.
- Vercel hostnames follow the DNS records Vercel asks for.
- Caddyfile contains one site block per VPS hostname.
- Caddy reloads without errors.
- Ports
80and443are open to the VPS. - Cloudflare proxy status matches the protocol and port of the service.
- SSL/TLS mode is compatible with the origin certificate.
- Public notes use placeholder domains, IPs, keys, paths, and IDs.
What To Remember
Do not treat “the domain is broken” as one problem. Split it into ownership, DNS record, proxy status, HTTPS certificate, reverse proxy, app health, and deployment target. That mental model keeps a personal AI stack maintainable as it grows from one blog into many services.Metadata
Quick Reference
Typeguide
Statuspublished
Date2026-06-02
Retrieval Tags
cloudflarednscaddyhttpsvpsvercel
Related
deploy langflow on a vpsdeploy x-ui with caddy httpsvercel deploymentpublic tutorial hygiene