Guide · CDN

Self-Hosted CDN: Caching, Origin Failover and Bot Protection on Your Own Servers

A self-hosted CDN is one or more edge servers that you run in front of your origin. Before you build one, settle three things: where the edge nodes sit, what they cache and for how long, and which protection rules stand in front of the site. Nodekeeper's own edge, which runs on ports 80 and 443, does the caching, the backup origin and the request filtering from one panel. Bandwidth and servers are yours: it is software that manages them, not a hosted CDN service.

A typical case

A small studio runs a content site and a shop from one origin server in a single data centre. Most readers are in Europe, a growing share is in East Asia, and the pages are heavy with images and a few large downloads. Twice this quarter the origin restarted during a deploy and visitors saw errors. Meanwhile a scanner keeps requesting the same login paths. The studio has two spare servers it can place closer to its readers and wants an edge layer it controls.

The picture below is the layout this guide plans for. A visitor's lookup returns the nearest edge node; the edge answers from cache when it can and goes to the origin only when it must.

Visitors, edge nodes and origin Visitors ask authoritative DNS with GeoDNS rules which edge node is nearest. They then connect to the edge node in their region. Each edge node serves cached content and applies protection rules, and goes to the origin only on a cache miss. The origin has a primary server and a backup server; a dead origin is dropped and traffic goes to the backup. Visitors Europe East Asia Authoritative DNS with GeoDNS Nearest edge node · Business 1 · Which edge? Edge node · Europe Cache · stale copy on error IP · GeoIP · JA3 · rate limit Your server, your bandwidth Edge node · East Asia Cache · stale copy on error IP · GeoIP · JA3 · rate limit Your server, your bandwidth 2 · HTTPS Origin Primary originYour content lives here Backup originTakes over when theprimary stops answering 3 · miss 3 · miss
Planned layout: DNS picks the edge, the edge answers from cache, and only a miss goes to the origin. Every edge tries the primary origin first and uses the backup only when the primary stops answering. The DNS step needs Business; on Personal you run the edge and point your domain at it yourself. On a narrow screen, scroll the diagram sideways.

Decision 1: how many edge nodes, and where

Start from your visitors, not from your servers. Look at where readers come from, pick the one or two regions that hurt most, and put one edge node in each. A single edge node already gives you the cache, the backup origin and the filtering. More nodes only shorten the distance for visitors who are far from the first one.

  • One node first. Run the CDN site on one server, point your domain's DNS at it, and watch the hit rate for a week before adding a second node.
  • Several nodes, one configuration. A sync group keeps the rules, CDN sites and forwarding settings of several edge nodes the same, so a change is made once. Sync groups are a Business feature.
  • Sending visitors to the nearest node. Nodekeeper's authoritative DNS supports GeoDNS rules by continent, country, region and city, and a per-record CDN switch on A, AAAA and CNAME rows: turning it on publishes your edge nodes' addresses, keeps the old value as the origin and creates the CDN site for you. Turning it off restores the original record. This is Business, and it applies to domains hosted on Nodekeeper DNS.
  • Certificates follow the nodes. Issued and renewed certificates can be synced to the node group you choose, and only that group receives the private key.

This guide covers failover to a backup origin. It does not cover moving visitors between edge nodes when a whole node is down: treat that as its own decision, together with the DNS and TTL choices you make for the domain.

Decision 2: what to cache, for how long, and what happens when the origin fails

Caching is a list of promises about how stale a page may be. Write the list before you set a single TTL.

Content types, a sensible cache stance for each and what to watch
ContentStanceWatch for
Images, CSS, JavaScript, fontsCache for a long timeVersion the file name when you change a file, so visitors do not keep an old copy.
Public HTML pagesCache brieflyA short TTL keeps edits visible quickly while still absorbing traffic spikes.
Large downloads and videoCache, with a per-file size limitPartial (Range) requests are served from cache, and several visitors asking for the same part make one request to the origin.
Logged-in pages, carts, checkoutDo not cacheLeave these paths out of the cache rules, and check which methods and status codes each rule covers.

In the cache settings you give each path pattern its own TTL, maximum size per file, methods and status codes. You also choose what the cache key is built from: the query string, the Host header, the client IP and the User-Agent. Every part you add splits the cache into more copies, so add only what changes the page.

Cache tab of the New CDN site dialog: switch to serve a stale copy when the origin returns 5xx or times out, a permanent fallback, log retention, a size limit per file, the cache key parts, and a table of path rules with TTL, size limit, methods and status codes
Cache settings in the New CDN site dialog: per-path TTL and size limits, and stale cache served when the origin fails. The values shown are the dialog's defaults.

Stale-on-error: the setting that keeps the site up during a deploy

With stale-on-error on, an origin that answers with a 5xx error or times out no longer shows visitors an error page for anything the edge already has: the edge serves the old copy instead. A separate permanent-fallback switch serves the cached copy whenever one exists. The order is fixed: a normal cache hit first, then the stale copy if the origin fails, then a 502 for what was never cached. So it protects pages people have already requested, and it cannot invent a page the cache has never seen.

More than one origin

Give a site a primary origin and a backup origin. An origin that stops answering is dropped from rotation automatically and traffic goes to the backup; the edge keeps checking the dead origin and puts it back when it responds. A site with a single origin still retries a failed request, but has nowhere else to send it.

Decision 3: which protection rules, in which order

This is a suggested order to set the rules up, not the order the edge evaluates a request.

  1. Know what an allow set does. Once an allow set is attached to a site, the site accepts only those addresses and refuses everyone else. Do not attach one to a public site; use it only to protect an admin path or an internal site.
  2. IP and region rules. IP and CIDR sets (IPv4 and IPv6) deny (or, as above, exclusively allow) source addresses per site. GeoIP rules block or allow by country, city, ASN, and, with the commercial database, by ISP and connection type. An allow rule here also refuses every other region.
  3. TLS fingerprints. A JA3 / JA4 blocklist drops a connection before the TLS handshake completes. It suits scanners and bots whose fingerprint is stable. The list can be global or per site.
  4. Rate limits. Cap requests per IP in a time window, globally, per site or per URL prefix. When an IP goes over, the action can be a straight block (429), a JavaScript challenge or an image captcha, with a grace count and a block duration you set.
  5. Human verification. Challenge suspicious IPs with a proof-of-work or captcha page before blocking them. Passing sets a cookie.
  6. WAF rule sets. Attack-pattern filtering for each site. A new CDN site does not go through the WAF until you tick at least one WAF rule set on the site's Security tab.
  7. Escalate repeat offenders. An optional switch passes an IP that keeps tripping the rate limit to the system firewall, so it is dropped at the network layer. The block expires after the time you set. It is off by default. Before you turn it on, put your own office and monitoring addresses on its whitelist so you cannot lock yourself out.
Global JA3 and JA4 TLS fingerprint blocklist: each entry shows a fingerprint hash, a label, its source, whether it is enabled and its hit count
The global JA3 / JA4 TLS fingerprint blocklist: a connection matching an entry is dropped before the TLS handshake. The entries here are curl and Reqable fingerprints.
Two behaviours to plan around. Rate-limit counting is asynchronous, so a fast burst can let a few extra requests through before the limit takes hold. And the firewall step needs nftables on the host: without it the layer-7 rules still apply and the firewall step is skipped. Each node blocks on its own; blocks are not shared between nodes.

What Nodekeeper does for you

Everything below is in the same panel, and the edge itself is Nodekeeper's own software rather than something you assemble from separate parts.

The self-hosted CDN capabilities in this guide and the plan each one starts with
What you decidedWhat Nodekeeper gives youStarts with
An edge on your own serverCDN sites on Nodekeeper's in-house edge, ports 80 and 443Personal
What to cachePer-path TTL, file size limit, methods and status codes; cache key choices; Range cache for large files and videoPersonal
Staying up when the origin failsStale-on-error, permanent fallback, several origins and a backup origin with automatic recoveryPersonal
Changing what visitors seeHeader rewrite, content replace and redirects at the edgePersonal
Who gets inIP / CIDR sets, GeoIP rules, JA3 / JA4 blocklist, per-IP rate limits, human verification, firewall stepPersonal
HTTPS on every edgeCertificate issuing and renewal, synced to the node group you chooseEvery plan
Seeing the trafficCDN sites appear in the same analytics list as your other sitesPersonal
Several edge nodes, one setupSync groupsBusiness
Nearest node by regionAuthoritative DNS with GeoDNS and a per-record CDN switchBusiness
Origins that check browser fingerprintsHigh-performance origin fetch with browser fingerprint impersonation, HTTP/3 and proxy support, chosen per siteBusiness
Analytics site list showing a CDN site, two domain aggregates and a standalone site, each with page views, visitors and IPs for the day; domains redacted
One list for every tracked site: CDN sites, domain aggregates and standalone sites. Domains are redacted.

If you resell CDN through a billing system or the hosting API, that side of it is Business.

Limits to know before you build

Your servers, your bandwidth. Nodekeeper is software that manages your edge nodes. It is not a hosted CDN network, and it does not supply servers, bandwidth or locations.
GeoIP. Country, city and ASN rules work with the free GeoLite2 database, which Nodekeeper downloads and refreshes monthly. ISP, domain and connection-type rules need the commercial MaxMind GeoIP2 database; without it, rules on those fields never match. IP geolocation is an estimate, so keep a way in for visitors who are placed wrongly.
ESXi nodes have no nftables, so the firewall step does not apply there.
The WAF is opt-in per CDN site. Tick a rule set on the Security tab, or the site is not filtered by it.

Questions people ask

Is this a hosted CDN I can rent?

No. You run the edge nodes on your own servers and pay for their bandwidth yourself. Nodekeeper is the software that turns them into a CDN and manages them from one panel.

Do I need Business to use a CDN?

No. CDN sites, cache rules, stale-on-error, backup origins and the protection rules start with Personal. Business adds sync groups for several nodes, authoritative DNS with GeoDNS, and the per-record CDN switch.

What happens to pages the cache has never seen when the origin is down?

The edge can only serve what it has stored, so those requests get a 502. That is why a backup origin matters as much as stale-on-error: one covers cached pages, the other covers everything else.

Can I see CDN traffic next to my other sites?

Yes. CDN sites appear in the same analytics list as domain aggregates and standalone sites. Heatmaps and replay are off by default for each site, and script-based analytics is not a count of total traffic.

Try a CDN site on your own server

Put the cache and the protection rules in front of one site first, then decide whether a second node is worth it. CDN sites are included from Personal.

Start Personal Trial

30-day trial of Personal: monthly subscription, first month $0, card required, once per account, up to 3 nodes. Cancel before day 30 and you are not charged; after that, Personal renews at $3 per node per month.

Prefer to start on the free plan? Download it and add Personal when you are ready for the CDN. Compare plans on the pricing page.

Related

N Nodekeeper

Manage websites, office PCs and servers from one panel on your own hardware.

Support
support@host.mw WhatsApp: +817093066006

© 2026 Nodekeeper. All rights reserved.