ZhuoQi Devzhuoqidev.com← Back to deskRSSllms.txt
~/posts/hugo-dual-cdn-blog.md
TinkeringUpdated ~3,500 words · 15 min read

One Static Site, Two Clouds — Serving China from Alibaba Cloud and Readers Abroad from Cloudflare (November 2026 Edition)

TL;DR

A personal site that loads fast both inside and outside China does not need a server. The same static files go to Alibaba Cloud for China and to Cloudflare for readers abroad, and DNS sends each visitor to one of them, provided the domain has an ICP filing first. That is a registration with China's Ministry of Industry and Information Technology, required before a mainland server or CDN may serve the domain, and it takes a few days to about a month. No server is needed for it either; a ¥101 Alibaba Cloud resource pack (a prepaid cloud product, bought only because a filing must be attached to one) carries it. This site has run that way since May 2026 for about ¥207 a year by the bills, mostly the domain and that resource pack; Cloudflare has cost nothing. Whether the pack must be renewed to keep the filing is still to be confirmed with Alibaba Cloud. Good for blogs and docs read both in China and abroad; skip it if nearly all your readers are abroad and use Cloudflare alone. Setting it up is the easy part. Keeping both sides on the same version is the work, and every step and pitfall is laid out below.

Contents
  1. The short version
  2. What you need
  3. How the pieces connect
  4. ICP filing without a server
  5. Split DNS: two records, and mind which one is the default
  6. From Hugo to Astro
  7. One deploy: build once, publish twice, check the commit
  8. Four Alibaba Cloud OSS pitfalls
  9. Certificates: checked weekly, renewed at 30 days
  10. A little server code on a static site: guestbook and visit counts
  11. What it actually costs per year
  12. When this is worth doing

The short version

  • One domain, two lines. Visitors in China resolve to Alibaba Cloud CDN (a service that caches pages on nodes across the country so readers fetch from a nearby one), backed by OSS (Alibaba Cloud’s file storage; this site’s bucket is in Shenzhen); visitors abroad resolve to Cloudflare Pages (Cloudflare’s static site hosting, free for personal use). DNS is the phone book that can return different addresses depending on where the caller is, and Alibaba Cloud DNS lets you set a separate “overseas” line on its free plan, with everyone else on the default line.
  • It starts with an ICP filing. Alibaba Cloud’s mainland CDN nodes only serve domains registered with China’s Ministry of Industry and Information Technology. You can file without renting a server: a ¥101 Function Compute resource pack serves as the “filing carrier”.
  • Build once, publish twice, then check the commit. Both sides receive the same build output (the dist/ folder). After publishing, the pipeline reads a small file holding the commit hash from each side; if they disagree, the deploy fails.
  • About ¥207 a year. Domain ¥90, filing resource pack ¥101, CDN traffic pack ¥14, OSS about ¥2; Cloudflare is free.
  • Good for fully static sites with readers both in China and abroad (blogs, docs, portfolios); not for apps that need a server, or sites whose readers are almost all outside China (Cloudflare alone is enough). The filing takes a few days to about a month, and readers in China make do until then.
Yearly cost¥207From the May–October 2026 bills
One deployabout 4 minPush to confirmed live on both sides
Cloudflare spend¥0Pages, Functions and D1 all within the free tier

A few terms first:

TermWhat it means here
Static site generator (Hugo, Astro)A tool that compiles Markdown articles into plain HTML, CSS and image files that can be served from anywhere, with no server program
OSSAlibaba Cloud’s object storage: a pay-as-you-go folder in the cloud where the site’s files live
CDNCaches files on nodes near readers; readers fetch from the nearest node, and OSS is only asked when a node lacks the file (a “fetch from origin”). “Refreshing the CDN” means telling the nodes their cached copies are out of date, so they fetch new ones from OSS
Cloudflare PagesCloudflare’s static hosting: upload a folder and it serves it from its global nodes at a *.pages.dev address, free for personal use
ICP filing / provincial authorityTo run a site on servers or CDN in mainland China, the domain must first be registered with the Ministry of Industry and Information Technology; each province’s communications administration reviews it
Function ComputeAlibaba Cloud’s function hosting: upload code, it runs only on requests and bills by use; here it is just the filing ticket
Cloudflare Pages FunctionsSmall pieces of server code deployed with Pages that run only on requests; the guestbook and visit counts run on them
D1Cloudflare’s hosted database (SQLite), where guestbook notes and visit counts live
GitHub ActionsGitHub’s built-in automation: push code and it builds and publishes on GitHub’s machines, free for public repositories

What you need

  • A domain, with real-name verification done.
  • An Alibaba Cloud account, with real-name verification done.
  • An Alibaba Cloud product to carry the filing: mine is the ¥101 Function Compute resource pack (see the filing section below).
  • A Cloudflare account; the free plan is enough.
  • Uploading needs neither Git nor the command line: the finished site folder can be uploaded by hand in both consoles. Cloudflare Pages accepts a folder or a zip dragged into the dashboard (direct upload, up to 1,000 files of up to 25 MiB each); the Alibaba Cloud OSS console keeps a folder’s structure when you drag the folder into its upload area (uploading folders). By hand, every update has to be uploaded to both sides; the automated pipeline in this article is the advanced way.

How the pieces connect

There are two paths to keep apart: the path a reader’s request takes, and the path a new article takes when I publish.

For the reader, DNS first looks at where the visitor is.

Reader opens zhuoqidev.com · DNS: where is the visitor? · Cloudflare Pages worldwide nodes · Alibaba Cloud CDN mainland nodes · Alibaba Cloud OSS the file bucket · Overseas · Everyone else (default)
View source (Mermaid)
mermaid9 lines of code
flowchart LR
    R(["Reader opens zhuoqidev.com"]) --> D{"DNS: where is the visitor?"}
    D -->|"Overseas"| CF["Cloudflare Pages<br>worldwide nodes"]
    D -->|"Everyone else (default)"| CDN["Alibaba Cloud CDN<br>mainland nodes"]
    CDN --> OSS["Alibaba Cloud OSS<br>the file bucket"]
    classDef cn fill:#fff3bf,stroke:#f08c00
    classDef os fill:#d0ebff,stroke:#1971c2
    class CDN,OSS cn
    class CF os

For publishing, the site is built once and both sides get the same files.

Push to GitHub main · GitHub Actions builds once continues only if checks pass · Upload to Alibaba Cloud OSS then refresh the CDN · Upload to Cloudflare Pages · Read deploy-manifest.json from each side success only if every commit matches
View source (Mermaid)
mermaid10 lines of code
flowchart TD
    P(["Push to GitHub main"]) --> B["GitHub Actions builds once<br>continues only if checks pass"]
    B --> O["Upload to Alibaba Cloud OSS<br>then refresh the CDN"]
    B --> C["Upload to Cloudflare Pages"]
    O --> V["Read deploy-manifest.json from each side<br>success only if every commit matches"]
    C --> V
    classDef cn fill:#fff3bf,stroke:#f08c00
    classDef os fill:#d0ebff,stroke:#1971c2
    class O cn
    class C os

Why not just one provider:

  • Cloudflare only: free and fast worldwide, but slow and unreliable from mainland China, where about 70% of this site’s readers are (computed on 2026-10-27 from the previous 30 days of Cloudflare analytics and Alibaba Cloud CDN logs, my own visits removed).
  • Alibaba Cloud only: fast in China, but overseas readers detour to mainland nodes; and I also want Cloudflare’s free functions and database for the guestbook (more below).

Both “slow”s are general experience from running sites in and outside China; I have not measured from multiple locations, so there are no numbers here.


ICP filing without a server

Mainland CDN nodes only serve filed domains. The filing goes through an “access provider” (the cloud company whose mainland servers or CDN will serve the site) such as Alibaba Cloud, which wants you to own a product there that can act as the “filing carrier”, usually a server. An individual can file under their own name: Alibaba Cloud has a separate quick start for personal websites (in Chinese), and its filing pages are the reference for the documents required.

If you don’t want a server, Alibaba Cloud’s Function Compute resource pack counts too: an order of ¥100 or more comes with one filing service code (the voucher you enter when filing, proving you are an Alibaba Cloud customer). I bought the cheapest tier, a one-year pack of 1.2 million CU (Function Compute’s unit of compute), list price ¥126, paid ¥101. Not one CU has been used. It is an entry ticket.

Per Alibaba Cloud’s filing process page (checked 2026-11-03), its own review takes 1–2 working days and the provincial authority’s usually 1–20 working days, which cannot be hurried: a few days at best, about a month at worst — enough time to build the site in the meantime.


Split DNS: two records, and mind which one is the default

In Alibaba Cloud DNS, one hostname can carry different records per line. Current configuration (checked 2026-11-03):

HostnameLinePoints toEffect
zhuoqidev.comDefaultAlibaba Cloud CDNChina, and anywhere not matched by another line, goes to Alibaba Cloud
zhuoqidev.comOverseaszhuoqidev.pages.devOverseas goes to Cloudflare
www.zhuoqidev.comDefaultAlibaba Cloud CDNEveryone goes to Alibaba Cloud
api.zhuoqidev.comDefaultzhuoqidev.pages.devEveryone goes to Cloudflare (guestbook and stats API)

www only has a default line, so overseas readers who type www. also detour to mainland nodes — a small wart I have left alone.

The domain does not have to move to Cloudflare: all DNS stays at Alibaba Cloud, and on Cloudflare’s side zhuoqidev.com and api.zhuoqidev.com are simply added as custom domains of the Pages project. Once Alibaba Cloud’s CNAME record (meaning “for this name, ask that name”) points there, Cloudflare verifies ownership over HTTP and issues and renews the certificate itself. On Alibaba Cloud’s side, two accelerated domains (the domains served through the CDN) are added in the CDN console with the OSS bucket as origin (where a node fetches a file it lacks), and the CNAME it gives you goes into the default line.


From Hugo to Astro

Readers who only want to set up a site can skip this section.

I researched the stack during the day on 2026-10-07 and the first answer was stay on Hugo: moving to Astro would take one to three weeks, and all it would buy was interactive components inside articles. The answer flipped the same day for one reason: all of this site’s code is now written by AI, so a switching cost counted in human hours no longer applied. The old site also had real problems:

  • English pages declared Chinese as their lang, the English RSS feed was empty, and search engines could not pair the two editions;
  • 47 4K images totalled 244 MB, and the heaviest article weighed 14.5 MB.

Work started that evening and the new site went live the same day, which bore the premise out. Astro rather than a framework like Next.js, because two-line hosting can only serve static files, so most server-dependent features would go unused; and the text has to be in the static HTML so AI crawlers that do not run scripts can still read it.

The biggest risk of a migration is broken links. The 274 URLs of the old site were saved as a list, and every build checks that each still opens (moved articles get redirect pages). That check still runs on every deploy. This article is an example: its address /en/posts/hugo-dual-cdn-blog/ did not change, only the content did.


One deploy: build once, publish twice, check the commit

After a push to main, GitHub Actions runs these stages in order; a failure at any stage publishes nothing:

Step 1 of 6

Check

Type checks, lint, unit tests, then one full build.

Step 2 of 6

Verify output

Legacy URLs, internal links, anchors, language pairs, image sizes, and each article's Markdown copy for AI readers. Anything wrong stops the run.

Step 3 of 6

Stamp the commit

Write deploy-manifest.json into the output with this Git commit and the build time.

Step 4 of 6

Publish to Alibaba Cloud

Sync to OSS (deleting stale files), fix content types and cache headers, then refresh the CDN (so its nodes drop their old copies).

Step 5 of 6

Publish to Cloudflare

Upload the same dist/ to Cloudflare Pages.

Step 6 of 6

Cross-check

Bypass DNS, connect straight to the Alibaba Cloud CDN addresses that serve zhuoqidev.com and www.zhuoqidev.com, and to pages.dev, and read deploy-manifest.json; success only when all three show this commit. Then spot-check content types and cache headers.

The six stages of deploy.yml (2026-11-03)

Why the last stage bypasses DNS: GitHub’s machines are in the US, so resolving zhuoqidev.com normally returns Cloudflare. Asking the domain alone would pass even if Alibaba Cloud never updated. The script connects to the Alibaba Cloud CDN node addresses directly and checks all three.

It also shows where two lines go wrong most easily. On 2026-10-11 and 10-13, after a package-manager switch, the Cloudflare step failed and the deploys did turn red; but the Alibaba Cloud step runs first and had already published. Readers in China saw new articles while readers abroad stayed on the last successful version from 10-09, and for two days nobody opened those two red runs. The lesson: when a two-line deploy fails, the two sides have probably already diverged, so a red run needs handling at once, not a fix that rides along with the next deploy.

From 25 minutes to 4

Right after the migration, a dozen-odd deploys took 9 to 25 minutes each. The build was not the slow part; shipping files to Shenzhen was:

Before (slowest run)After
Sync to OSS3 → 32 parallel uploads328 s → 29 s −91%Fix content typesstop rewriting 470 folder records137 s → 4 s −97%Install CJK fontsapt → direct download of a pinned version811 s → 4 s −100%
Single-step times before and after two changes on 2026-10-08 (GitHub Actions logs)
  • Alibaba Cloud’s CLI uploads 3 files at a time by default. A round trip from a US GitHub machine to Shenzhen takes about 0.25 seconds and each file needs several, close to a second per file on average; a thousand-odd files, three at a time, took about five minutes. With 32 in parallel it takes 29 seconds.
  • OSS has no real folders; it stands them in with empty records whose names end in /, about 470 for this site. The content-type step used to rewrite all of them on every run; with that option turned off it takes 4 seconds.
  • The build draws each article’s social card (the preview image shown when a link is shared) in a browser, and without Chinese fonts the Chinese on those cards is laid out wrong. Installing the fonts with the system package manager apt sometimes took over ten minutes; downloading a pinned upstream version takes 4 seconds.

Recent deploys mostly take about 4 minutes from push to confirmed live on both sides.


Four Alibaba Cloud OSS pitfalls

Cloudflare Pages works as soon as the upload finishes. Alibaba Cloud OSS is general object storage, and serving a website from it needs a few fixes. All four were hit for real:

1. Garbled Chinese pages

  • What you see: Chinese .md files and llms.txt (a plain-text summary of the site for AI tools) show up in the browser as garbled characters.
  • Why: OSS sets content types without charset=utf-8, and has no type at all for .md.
  • Fix: re-upload those files with an explicit type and charset.

2. Scripts 4× larger on the China line

  • What you see: three.js (a 3D library some pages load) is about 4× its overseas size on the China line, 581 KB vs 144 KB.
  • Why: OSS only compresses a fixed list of types, and the text/javascript it assigns to .js is not on it.
  • Fix: label .js as application/javascript; enable only gzip on the CDN, whose brotli (another compression format) came out larger than its gzip.

3. Old headers after a CDN refresh

  • What you see: headers you changed are still the old ones after refreshing the CDN.
  • Why: a refresh only marks cached copies stale; the node asks OSS “has this changed?”, an unchanged file gets “not modified” (HTTP 304), and the node keeps the old headers.
  • Fix: refresh the affected files one by one.

4. Returning readers see the old article

  • What you see: readers who visited before still get the old version of an updated article.
  • Why: OSS sends no cache header for HTML, so browsers guess a lifetime from the last-modified time.
  • Fix: send max-age=0, must-revalidate on every file (check for a newer version every time; Cloudflare’s default), and a one-year cache on hashed asset names (file names that change whenever the content changes, so an old name never needs updating).

The last fix has a price: Alibaba Cloud CDN no longer caches HTML at the node and fetches it from OSS each time. In Alibaba Cloud CDN’s own access logs, after the change on 2026-10-25 an HTML request with nothing cached at the node, fetched from OSS, took 64–196 ms; before it, a request served from the node’s cache after a quick “has this changed?” check with OSS took 85–117 ms, a few dozen milliseconds more at the slow end. I accept that so readers never see a stale article.


Certificates: checked weekly, renewed at 30 days

A certificate is what makes the address https, with the padlock in the address bar; without a valid one the browser warns that the site is not secure. Cloudflare manages its own certificates; the ones on Alibaba Cloud CDN must be uploaded by you. The site started with Alibaba Cloud’s free DigiCert certificate; when it expired in August 2026 the free quota was used up, so it switched to Let’s Encrypt (a free, non-profit certificate authority). Its certificates last 90 days today, 64 days from 2027-02-10 and 45 days from February 2028, and manual renewal is bound to be forgotten, so renewal has to be automatic:

  1. A scheduled job runs every Monday. It reads how many days the certificate on each CDN domain has left and exits if both have more than 30.
  2. Below 30 days, acme.sh (an open-source script for requesting Let’s Encrypt certificates) proves the domain is mine with a temporary record in Alibaba Cloud DNS, issues one certificate covering both the bare domain and www, and uploads it to both CDN domains.
  3. It reads the certificate fingerprint back from both CDN domains; success only if both match what was uploaded, HTTPS works, and the temporary record is gone. The private key lives only in that run’s temporary directory, never in a cache or the repository.

It has acted for real once: the old certificate would have expired on 2026-10-31; the scheduled run on 2026-10-05 found 26 days left and issued a new one ahead of that, which is valid on both domains until 2027-01-03 (read with openssl on 2026-11-03). Every weekly run since has been “renewal not needed”, exiting in about ten seconds. Once certificates shrink to 45 days, “check weekly, renew below 30 days” still works; it just renews about every two weeks.

An interlude: in August 2026 a payment problem on the GitHub account stopped jobs from even getting a machine. For a while the certificate job ran on a VPS of my own (a “self-hosted runner” in GitHub’s terms), and deploys were run by hand from a Mac. At the end of August everything moved back to GitHub-hosted machines (free for public repositories) and the VPS was retired.


A little server code on a static site: guestbook and visit counts

Readers who only want to set up a site can skip this section.

The site itself is still static. The only server code is Cloudflare Pages Functions (small functions deployed with Pages), with data in Cloudflare’s D1 database, currently 164 KB. Guestbook notes are held for review before they appear; visit counts store no IP. A person is counted once a day by hashing the IP together with a random string generated each day (the salt); the next day the salt and the hashes are deleted, after which nobody can recover the IP.

The hard part is the China line: Alibaba Cloud CDN does not run functions, and the stats beacon (a small request a page sends quietly when it opens, used for counting) that crosses the border to Cloudflare is often lost. Checking against CDN logs from 2026-10-09 to 10-11, the beacon recorded only a little over half of the actual readers each day. So the two lines are counted separately:

Overseas (Cloudflare)China (Alibaba Cloud)
CrawlersThe function counts by User-Agent in real timeCounted each morning from the previous day’s CDN logs
PeopleThe page sends a beacon to api.zhuoqidev.comThe page requests /hit.gif, also counted from CDN logs and placed by province with an offline IP database
DelayReal timeOne day (Alibaba Cloud’s logs arrive hours late)

How a page knows which line served it: the Cloudflare function adds a Server-Timing marker to the response. The page script sends the beacon when it sees the marker and requests /hit.gif when it does not.

Free tier (Cloudflare docs, checked October 2026): 100,000 function requests a day; D1 allows 5 million rows read and 100,000 written a day. Static files bypass the functions (_routes.json excludes them) and use none of that, and the project is set so that if the allowance runs out, pages still load and only counting and the guestbook pause. On 2026-11-01 third-party analytics were cut down to Cloudflare Web Analytics; Google Analytics (GA4) and Baidu Analytics were removed.


What it actually costs per year

From the Alibaba Cloud bills (May–October 2026) and the Cloudflare account’s subscriptions:

Function Compute packfiling carrier, one year, list ¥126¥101Domain¥270 for 3 years, to 2029-05¥90CDN mainland traffic pack100 GB for a year, list ¥20¥14OSS storage and traffic¥1.05 over six months, annualised¥2CloudflarePages, Functions, D1, analytics¥0
About ¥207 a year in total (bills checked 2026-11-03)

Is the traffic pack enough:

CDN mainland traffic pack2026-05-04 to 2027-05-0441 GB / 100 GB 41%
41.4 GB used in six months, about 7 GB in the last month; it will not run out before it expires

Certificates come from Let’s Encrypt and Cloudflare at no cost. For scale: in the 30 days before 2026-10-27 the site had about 550 readers, and the China line uses about 7 GB a month.

The old edition said ¥212 because it used the traffic pack’s list price and an estimate for OSS. The real fixed costs are the domain and the filing ticket; if traffic grows several times over, only the traffic line changes (once the pack runs out, traffic is billed by use; I have never got there). For the pay-as-you-go rate, Alibaba Cloud’s help center gives ¥0.24 per GB for the 0–10 TB tier of mainland China traffic billing, noting that the figure is an example and the official quote prevails (billing rules, checked 2026-11-03).


When this is worth doing

Worth it:

  • Most readers are in China but some are abroad — a Chinese-language tech blog, an open-source documentation site.
  • The site can be fully static (blog, docs, portfolio), and the occasional server feature can live in Cloudflare functions that the China line routes around.

Skip it:

  • Readers are almost all outside China: use Cloudflare Pages alone, no filing, no cost.
  • The site needs a server (logins, a database, live data): the whole point of two lines is that both sides only hold files. If you need a server, start with What does it cost to run an app online each month?, which works out the bills for servers and the various hosting options.
  • You can’t wait for a filing: it takes a few days to about a month, and until then readers in China have to make do with Cloudflare.
  • A company or team site: the architecture is the same, but the filing goes through the company as the applicant with more paperwork, and a private repository pays for GitHub Actions minutes beyond the free allowance. I have not been through either myself.

One domain, two lines: the money goes to the tickets (domain + filing), the care goes to consistency. As long as every deploy checks the same commit on both sides, two lines are as easy to live with as one.

$ For agents: index.md(plain Markdown, ~25 KB)

Say hi on WeChat

Liu ZhuoQi's WeChat QR code

Scan it in WeChat, or long-press it on your phone

Mention why you're reaching out, or I might miss it.

Scroll or pinch to zoom · drag to pan · double-click to toggle