Tools · 6 min read · Updated

Cloudflare Rules for Ghost: Protect the Admin and Member Sign-Ups, and Cache the Blog at the Edge

Copy-ready Cloudflare custom, rate limiting and cache rules for self-hosted Ghost, checked against a fresh Ghost 6.77 install: protecting the admin, stopping member sign-up spam, and caching the public site at the edge without serving members the wrong page.

Cloudflare rules for ghost

Ghost is fast and lean, and its public pages are almost the same for every visitor, which makes it one of the best fits for Cloudflare’s edge cache. Its weak spots are elsewhere: the admin at /ghost/, and member sign-ups, where bots abuse the magic-link form to send emails to addresses that never asked for them.

These rules are for self-hosted Ghost (on Ghost(Pro), Ghost runs its own CDN and you can’t put Cloudflare in front of it the same way). We checked every path against a fresh Ghost 6.77 install; the rules suit Ghost 5 as well.

What a fresh Ghost exposes

Terminal output from a fresh Ghost 6.77 install: the site endpoint reveals version 6.77, the generator meta tag, the setup endpoint status and a 403 from the Content API without a key
A fresh Ghost 6.77, before any rules.
PathResponseNotes
/ghost/api/admin/site/200, includes "version":"6.77"Public by design: the admin app reads it before login. Don’t block it
Every page’s <meta name="generator">Ghost 6.77Added by {{ghost_head}}. Hiding your version isn’t realistic with Ghost; keeping it updated is what counts
/ghost/api/admin/authentication/setup/{"setup":[{"status":false}]} until the owner existsOn a brand-new install, whoever reaches /ghost/ first creates the owner account
/ghost/api/content/posts/403 without a keyThe Content API key is public (it’s in your theme’s JavaScript) but read-only
/members/api/send-magic-link/POST only; refused without a valid integrity tokenThe sign-up and sign-in form
Ghost 6 Welcome to Ghost setup screen asking for site title, name, email and password
The setup screen of a fresh install. Finish it the moment the site is reachable, or block /ghost/ to your IP until you have.

Ghost already protects some of this

Ghost’s default configuration includes brute-force protection. From its defaults.json:

SettingDefaultMeaning
spam.user_login4 free retries, then a wait starting at 10 minutes, rising to 7 daysStaff login guessing
spam.user_reset4 free retries, then 1 hourPassword reset requests
spam.user_verification4 free retries, then 1 hourStaff device verification codes

Ghost also asks staff to confirm new devices with an emailed code (staff device verification), and member sign-up forms require an integrity token fetched by the page, which stops the simplest bots. Behind Cloudflare, though, Ghost sees Cloudflare’s IP addresses unless your web server passes on the real visitor IP, and then its per-IP limits treat thousands of visitors as one. Fix that first.

Before you start

1. Pass the real visitor IP to Ghost

Most self-hosted Ghost sites run behind Nginx (Ghost-CLI sets this up). Tell Nginx to trust Cloudflare’s ranges and use their header, so the address Nginx passes to Ghost in X-Forwarded-For is the visitor’s:

# /etc/nginx/conf.d/cloudflare.conf. Full list: https://www.cloudflare.com/ips-v4 and /ips-v6
set_real_ip_from 173.245.48.0/20;
set_real_ip_from 103.21.244.0/22;
# ...one line per range...
real_ip_header CF-Connecting-IP;

2. Keep Ghost updated

Ghost releases often. Self-hosted, update with ghost update (Ghost-CLI) regularly; no firewall rule replaces it.

3. SSL mode: Full (strict)

Set SSL/TLS to Full (strict) with a valid certificate on the server. “Flexible” makes Ghost think requests arrive over HTTP while its url is HTTPS, causing redirect loops.

Security rules

Rule 1: Challenge the admin

Action: Managed Challenge.

(starts_with(http.request.uri.path, "/ghost/") and not starts_with(http.request.uri.path, "/ghost/api/content/"))
and not ip.src in {203.0.113.10 198.51.100.0/24}

Replace the IPs with yours, or remove that line. The Content API is left out because your theme calls it from visitors’ browsers for search and other features. If your team works from anywhere, Cloudflare Zero Trust Access (free for up to 50 users) in front of /ghost/ is stronger.

What it might break: integrations that use the Admin API (/ghost/api/admin/) from their own servers, such as Zapier or a custom script. Add their IPs to the exception, or skip the API path for them.

Rule 2: Block probes for other platforms

Action: Block.

(http.request.uri.path in {"/wp-login.php" "/xmlrpc.php" "/wp-admin/" "/administrator/" "/user/login"})
or (http.request.uri.path contains "/.env")
or (http.request.uri.path contains "/.git")
or (ends_with(http.request.uri.path, ".php"))

Ghost is a Node.js application and never serves .php files, so every request ending in .php is a scanner looking for WordPress, Joomla or a web shell. Blocking them at the edge keeps that noise out of your logs and off your server.

Rate limiting: member sign-ups and staff login

Sign-up abuse is the Ghost problem that costs real money and reputation: bots submit thousands of addresses to your sign-up form, Ghost emails each a magic link, and your email provider sees bounces and spam complaints from people who never signed up. With the one path-only rule on the Free plan, protect the magic-link endpoint:

  • If incoming requests match: URI Path equals /members/api/send-magic-link/
  • Characteristics: IP
  • Requests: 5 per 10 seconds
  • Action: Block for 10 seconds

A real person signs up once. On paid plans, add a second rule for the staff login (/ghost/api/admin/session, POST) and longer windows (a few per minute).

Also, in Ghost’s admin, check Settings → Membership: if you don’t run a newsletter or memberships, set sign-up access to Nobody (invite-only or off), which removes the target completely. The site endpoint’s allow_external_signup: true in our test shows sign-ups are open on a fresh install. Ghost also has a list of blocked email domains for sign-ups in the same settings area.

Cache rules: the big win

Ghost’s public pages are the same for every anonymous visitor, so caching the HTML at Cloudflare’s edge makes them load from the nearest data centre and takes nearly all traffic off your server. The trick is never serving a cached page to a logged-in member or staff member, whose pages differ (paywalled content, the member portal).

Cache rule 1: Bypass for admin, members and previews

(starts_with(http.request.uri.path, "/ghost/"))
or (starts_with(http.request.uri.path, "/members/"))
or (starts_with(http.request.uri.path, "/p/"))
or (starts_with(http.request.uri.path, "/.ghost/"))
or (http.cookie contains "ghost-members-ssr")
or (http.cookie contains "ghost-admin-api-session")

Action: Bypass cache. ghost-members-ssr is the member login cookie and ghost-admin-api-session the staff session (both names confirmed in Ghost 6’s source). /p/ is where Ghost serves post previews.

Cache rule 2: Cache everything else

(http.request.method eq "GET")
and not starts_with(http.request.uri.path, "/ghost/")
and not starts_with(http.request.uri.path, "/members/")
and not starts_with(http.request.uri.path, "/p/")
and not http.cookie contains "ghost-members-ssr"
and not http.cookie contains "ghost-admin-api-session"

Eligible for cache, Edge TTL: 2 hours (ignore origin), Browser TTL: respect origin. Ghost’s theme assets carry a version string (/assets/built/screen.css?v=…), so they can be cached much longer; Cloudflare caches them by default.

The cost of edge caching: a post you publish or edit can take up to the Edge TTL to appear for visitors. Either keep the TTL short (30 minutes to 2 hours), or purge the cache when you publish, for example with a Ghost webhook (Settings → Integrations → custom integration, “Site changed” event) calling Cloudflare’s purge API.

If you sell paid memberships with content visible only to members, test the cache carefully: a member must never get the public, truncated page from cache, and a visitor must never get the full one. The cookie bypass above handles this, because members always carry ghost-members-ssr.

Test everything

curl -s -o /dev/null -w "%{http_code}\n" https://blog.example.com/wp-login.php                   # 403
curl -sI https://blog.example.com/ | grep -i cf-cache-status                                       # HIT after a reload
curl -sI -H "Cookie: ghost-members-ssr=x" https://blog.example.com/ | grep -i cf-cache-status       # BYPASS
curl -s -o /dev/null -w "%{http_code}\n" https://blog.example.com/ghost/                           # 403 challenge page from outside your IPs

Then sign up as a member with your own address, log in through the magic link, and confirm you see member content, not a cached public page.

Summary

RuleActionStops
AdminManaged ChallengeStaff password guessing; takeover of an unfinished setup
Other-platform probesBlockWordPress and PHP scans
Magic-link rate limitBlock 10 sSign-up and email bombing
Private bypassBypassCached member and admin pages
Edge cacheCache 2 hNearly all origin load

More in this series: Cloudflare rules for WordPress, Next.js, Strapi, Joomla and Drupal.

Filed undereCommerceTools
Rupak Nepali
Written byRupak Nepali

Rupak Nepali is a web developer, manage Webocreation website and the author of six books:
Getting Started with OpenCart Module Development (Packt, 2013),
OpenCart Theme and Module Development (Packt, 2015),
OpenCart 4: Dev Guide for Themes & Extensions (2024),
OpenCart 4: User Manual (2025),
Cloudflare for the Enterprise Website (2026) and
The Technical Web Guide for Marketers (2026).
Rupak has built OpenCart stores and extensions since 2010, has published more than 600 tutorials on Webocreation, and shares free OpenCart extensions on GitHub.
Find Rupak on
GitHub | Amazon | LinkedIn | X | YouTube.

Leave a Reply

Your email address will not be published. Required fields are marked *