VPS Tutorials
Point a domain to a VPS: DNS records, Cloudflare and HTTPS
Configure delegation, A/AAAA/CNAME records, mail and TTL, then distinguish authoritative DNS, cached answers and hostname-aware origin tests. Review Cloudflare proxying and regional hosting conditions.

To open a VPS website through example.com, connect three separate pieces: authoritative DNS, a server that routes that hostname, and a certificate covering it. A working www with a broken apex, an old address or a certificate warning can come from different layers; do not assume every failure is DNS.
This guide explains delegation, record types, TTL, Cloudflare proxying and a verification sequence that keeps DNS, connectivity and HTTPS separate. All example IP addresses and domains must be replaced with your own.
The registrar records which nameservers are authoritative for the domain. The selected DNS provider holds its A/AAAA/CNAME and other records. Buying a domain from one company does not require using its DNS service.
If nameservers already delegate to Cloudflare, adding A records only in the registrar's old DNS zone does not update the active zone.
dig NS example.com +short
# 或 Windows
nslookup -type=NS example.com
These lookups show delegation through your resolver. When changing DNS providers, confirm registrar/parent delegation and query the authoritative servers directly. Copy all required website, mail and verification records before switching; coordinate DNSSEC/DS changes to avoid validation failures.
| Type | Value | Purpose |
|---|---|---|
| A | IPv4 address | Address a host |
| AAAA | IPv6 address | Reach a host over IPv6 |
| CNAME | Another hostname | Alias, often for www |
| TXT | Provider-specified text | Ownership verification, SPF or DKIM records |
| MX | Mail hostname and priority | Route incoming mail |
| NS | Nameserver hostname | Delegate DNS |
| CAA | Certificate authority policy | Restrict certificate issuance |
Not every website needs every type. A CNAME normally cannot coexist with other record types at the same name; ordinary apex CNAMEs conflict with SOA/NS, though providers can offer flattening/ALIAS behavior.
If CAA restricts issuance, authorize the actual CA needed for each requested name. For Let's Encrypt this includes letsencrypt.org where applicable; inherited and wildcard-specific policy can matter.
dig CAA example.com +short
Using the documentation address 203.0.113.10:
| Type | Name | Value | Example TTL |
|---|---|---|---|
| A | @ | 203.0.113.10 | 300 |
| CNAME | www | example.com | 300 |
@ means the apex, example.com. A provider may expect @, an empty field or a full name. Check its input rules. Using a CNAME for www lets it follow apex address changes; two A records are also possible but both need updating.
| Type | Name | IPv6 example |
|---|---|---|
| AAAA | @ | 2001:db8::1 |
Add a direct-origin AAAA only when that assigned IPv6 address reaches the correct service and firewall. These documentation addresses are not routable credentials. See IPv6 setup.
| Type | Name | Example address | Service |
|---|---|---|---|
| A | @ | 203.0.113.10 | Main website |
| A | blog | 203.0.113.10 | Blog |
| A | api | 203.0.113.10 | API |
| A | git | 203.0.113.10 | Gitea |
Several names may share one IP. Nginx/Caddy routes the web requests using the hostname, including Host; DNS does not select the application or its port. Configure multiple sites and corresponding TLS names.
| Type | Wildcard name | Example address |
|---|---|---|
| A | * | 203.0.113.10 |
A wildcard can answer otherwise undefined names, subject to DNS wildcard and delegation rules. It is not authentication or a wildcard certificate. Reject unknown names at the gateway and protect administration interfaces independently.
| Type | Name | Value |
|---|---|---|
| A | @ | 203.0.113.10 |
| MX | @ | Mail provider's hostname and priority |
| TXT | @ | v=spf1 include:... ~all |
The SPF line is an incomplete placeholder: use the exact policy for your actual senders, not include:.... MX and A can coexist. Original provider examples include Tencent business mail, Zoho and Google Workspace; check eligibility, region, subscription and DNS instructions rather than assuming universal availability.
For outgoing mail, configure SPF, DKIM and DMARC correctly; PTR belongs to the actual sending IP/provider. Correct DNS helps but does not guarantee inbox delivery. See mail deliverability.
TTL is cache lifetime in seconds, not an instruction that forces every client to refresh immediately.
| Situation | Original planning range | Use |
|---|---|---|
| Initial testing | 60–300 seconds if supported | Shorten caching while correcting records |
| Planned IP change | Lower to 60–300 in advance | Wait out the previous TTL before cutover |
| Stable configuration | 3600–86400 seconds | Reduce routine DNS lookups |
For an old 86400-second TTL, lowering it a day before migration is a useful starting plan. Existing caches retain the old lifetime; lowering TTL immediately before changing IP does not expire them. Keep old and new services compatible during the transition, account for negative caching and follow the DNS provider's supported minimum. A longer TTL is not itself a guarantee of faster website responses.
| Mode | Result and capability |
|---|---|
| Orange cloud / Proxied | DNS returns Cloudflare edge addresses; supported web traffic can use proxy security/cache features, subject to plan and configuration |
| Gray cloud / DNS only | Returns the configured destination; Cloudflare's standard HTTP proxy protections do not sit in that traffic path |
- Only supported A/AAAA/CNAME records can use standard proxying; MX/TXT cannot.
- If one same-name A/AAAA record is proxied, Cloudflare treats the set as proxied. A proxied CNAME-chain target can also put traffic through the proxy; cross-account/SaaS cases have additional rules. Check the returned answer and applicable configuration.
- Standard proxied records use Auto TTL, documented as 300 seconds; DNS-only TTL options depend on the plan.
- Inspect the selected proxy status when creating records; do not rely on a dashboard default.
Proxying does not guarantee complete origin secrecy: historical DNS, mail records or other services can reveal its address. Caching, WAF features and attack protection also depend on configuration and plan.
Use Full (strict) with a valid origin certificate. Forward scheme information correctly, including X-Forwarded-Proto $scheme where the local TLS gateway sets it; trust upstream forwarding only from the intended proxy. Flexible mode or inconsistent scheme detection can cause redirect loops.
Error codes distinguish failures: 521 typically means connection refused, 522 a connection timeout, 525 TLS handshake failure and 526 an invalid origin certificate. A missing certificate is not automatically 521/522. See origin connection troubleshooting.
Use DNS only or a separately supported product for ordinary SSH, database or game traffic; standard orange-cloud HTTP proxying does not forward arbitrary TCP/UDP. HTTP-01 can work through the proxy if the challenge reaches the origin and is not blocked/cached incorrectly. DNS-01 is another option. Temporarily disabling proxying changes exposure and is a deliberate troubleshooting choice, not a mandatory certificate step.
For a managed outbound connector, evaluate Cloudflare Tunnel with its access and protocol requirements. See basic Cloudflare setup.
Use command-line queries before relying on browser results:
# 看当前解析到哪个 IP
dig A example.com +short
# 指定用 Cloudflare 的公共 DNS 查(绕开本地缓存)
dig @1.1.1.1 A example.com +short
# 看完整过程,包括 TTL 剩余秒数
dig A example.com
# Windows
nslookup example.com 1.1.1.1
dig output includes ANSWER SECTION. A caching resolver usually shows the remaining TTL; an authoritative response generally shows the configured TTL. Public 1.1.1.1 is still a recursive caching resolver, not your domain's authoritative nameserver.
- Query an authoritative server from the confirmed delegation, for example dig @AUTH_NS example.com A +norecurse.
- Compare a public recursive lookup such as
dig @1.1.1.1 example.comand your local lookupdig example.com. - Test origin connectivity with the intended hostname.
curl -I http://203.0.113.10alone may reach a default site or deliberate rejection. For HTTPS, use curl --resolve example.com:443:ORIGIN_IP -I https://example.com/ with actual values and a valid certificate. - Test the normal domain route with
curl -I http://example.com, then HTTPS, certificate names and application response.
A failed bare-IP request does not prove DNS is correct or the server is broken. Check gateway routing, origin access restrictions and service connectivity.
# Windows
ipconfig /flushdns
# macOS
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
# Linux(systemd-resolved)
sudo resolvectl flush-caches
Choose the commands for your OS and installed resolver. Clearing local caches does not flush public resolvers, browser DNS-over-HTTPS caches or authoritative propagation.
New records may appear within seconds or minutes; existing answers and negative responses can remain cached until their TTL expires. The original 2–48-hour nameserver-change and up-to-24-hour first-registration windows are rough estimates, not universal deadlines. Registrar processing, parent delegation, DNSSEC and domain holds can also matter.
- Confirm records are in the active DNS zone.
- Check apex input
@has not accidentally createdexample.com.example.com. - Compare authoritative answers before clearing local caches repeatedly.
- Check registrar/registry holds.
.cnregistrations can have specific identity-verification requirements; other domains can be held for different reasons.
dig NS example.com +short # 1. NS 对不对
dig @1.1.1.1 A example.com +short # 2. 权威 DNS 有没有你的记录
curl -I http://你的IP # 3. 服务器本身通不通
This original sketch needs two corrections: the 1.1.1.1 query is recursive, and the IP placeholder must be replaced. Query the actual authoritative server and use a hostname-aware origin test before concluding which layer failed.
If www works, inspect the apex A entry @ and the provider's meaning of @. Entering example.com incorrectly may produce example.com.example.com. If only the apex works, add the missing www CNAME or A record and configure the gateway for both names.
The certificate must cover the requested name: example.com alone does not cover www.example.com. For an Nginx-managed site:
sudo certbot --nginx -d example.com -d www.example.com
Check both DNS names, CAA, certificate validity and renewal. HTTP-01 needs reachable port 80 and the correct challenge path on every relevant address. Check A/AAAA, firewalls, redirects, WAF/cache behavior and the ACME client. Proxying need not be disabled if validation passes through; use DNS-01 when suitable.
For slow mainland-China access with normal access elsewhere, compare actual routes, addresses, edge behavior and IP filtering. Do not assume DNS or claim specific Cloudflare mainland nodes were measured.
If the VPS cannot resolve external names, investigate its outbound resolver. A ping failure alone can also be ICMP filtering; confirm name resolution separately.
- Configure Caddy, Nginx/Certbot or Nginx Proxy Manager for the actual names and certificates.
- Establish SSH keys, guest/cloud firewall rules and verified protection using server hardening. Public IPs can be scanned even before DNS is configured.
- Plan rate limits and upstream protection against request floods as traffic requires.
For public websites hosted in mainland-China facilities, including applicable Alibaba Cloud or Tencent Cloud deployments, check the provider's ICP filing/licensing requirements before opening service. The domain's registrar location alone does not remove those requirements. This is a mainland-China hosting condition, not a worldwide DNS prerequisite.
Hosting outside mainland China, including Hong Kong, Japan or the US, does not use that mainland hosting-filing process simply to configure DNS. Other applicable obligations remain separate. Do not reduce the requirement to a universal promise that port 80 is always blocked or that every overseas service has no obligations. See the hosting/ICP guide.
Must domain and VPS come from one company? No. For example, a Namecheap domain can point to another provider using the active DNS service.
Can one name point to several VPSs? Yes, with multiple A/AAAA answers, but basic round-robin DNS has no inherent health checks. Clients may still select a failed address; monitored failover needs an appropriate service/design.
How do I move to another VPS? Prepare the new hostname/certificate/application, lower TTL early enough for the old value to expire, then change addresses while maintaining a controlled transition. With a one-day old TTL, the original advice is to lower to 300 a day ahead.
Is free DNS sufficient? It can suit small projects, but compare limits, support and required features. No measurement here establishes that Cloudflare is faster than most registrars.
When can a newly bought domain work? Often soon after registration and delegation, subject to registry/registrar processing, caches and holds. .cn may require particular identity verification; check the registrar's current rules.
Do subdomains need separate registration? blog.example.com and api.example.com belong to the parent domain. Creating DNS names normally needs no separate domain purchase, although DNS/provider application limits or fees can apply.
- Configure Caddy HTTPS.
- Route multiple sites on one host.
- Harden the server.
- Check mainland hosting conditions only when relevant.
- Diagnose service access after verifying DNS and hostname routing.