Skip to content

Docs

Camada for Cloudflare

Keep bad actors out of a site that already runs on Cloudflare, with no code changes. Keep HOSTS set to * for maximum domain-level edge coverage across your whole zone, so an attacker blocked on one host is blocked across all of them. Status: preview.

It is a Worker in your own Cloudflare account. It never sits in front of your site: it has no route, adds no latency. Every 5 minutes it:

  1. Reads your zone's request analytics from Cloudflare (the same data as Observability → Logs) and sends it to camada.
  2. Keeps a camada_block IP list and one WAF custom rule in your account in sync with the IPs camada blocks.

Your Cloudflare API token stays in your account. camada never sees it.

Install

Deploy to Cloudflare

Cloudflare copies the repo to your GitHub account and deploys it. You may need to install the Cloudflare Workers and Pages GitHub app first. The prompts ask for:

PromptMeaning
CAMADA_KEYFrom the camada dashboard.
CLOUDFLARE_API_TOKENThe token from the next section.
ZONEYour domain, for example example.com.
HOSTSKeep * for maximum domain-level edge protection (root domain and every subdomain at any depth). Or list comma-separated hostnames and subdomain wildcards such as www.example.com, *.api.example.com, *.*.*.example.com.

Leave CAMADA_URL as it is.

The API token

Create the token. The form asks for four permissions:

PermissionAccess
Zone > AnalyticsRead
Zone > ZoneRead
Zone > Zone WAFEdit
Account > Account Filter ListsEdit

Narrow the token to your one zone and your account. If the form shows fewer than four permissions, add the missing ones by hand.

What to expect

  • IP-level blocks, plus path and header exemptions. Blocks match IP addresses (no ASN or country entries), while Project Settings excluded paths, Allow-list path and header entries, and single-condition path/header Skip rules (is, starts with, contains) are exempted directly in the camada:block v1 WAF rule (within Cloudflare's 4 KB expression limit). Excluded paths are also skipped from analytics ingest.
  • About 10 to 17 minutes from the first bad request to the block: up to 5 minutes until the next run, about 2 minutes of Cloudflare analytics delay, then camada's analysis, then the next list sync.
  • Verified good bots (search engines and the like) get in. The rule exempts them.
  • A 48-hour dead-man's switch. If the Worker stops running, the rule expires on its own within 48 hours, so nothing stays blocked forever.
  • On busy minutes Cloudflare stores only a sample of the request rows. camada still gets per-IP request counts, which Cloudflare estimates for the whole minute, so volume-based blocks keep working. Billing counts the rows shipped.
  • Cloudflare's analytics carry no request headers. An injection attempt seen here can recommend a block but never applies one by itself. Blocks come from volume and behaviour (scanners, credential stuffing, probing), plus your manual blocks and rules.
  • It creates one list, camada_block, and one rule, camada:block v1. It never touches lists or rules it didn't create.
  • Built to run on every plan, including Free: no Logpush, no Enterprise features and no storage. Free allows 1 list and 5 custom rules. If there is no free slot, Setup in the camada dashboard shows what to fix, and analytics keep flowing meanwhile.

Updating

Most fixes ship on camada's side, so usually there is nothing to do.

When Setup in the dashboard says your Worker is out of date:

  1. Download the source code (zip) of the latest release and unzip it.
  2. In your copy of the repo, replace the src/ folder with the one you unzipped, then commit and push.

Cloudflare redeploys the Worker within a few minutes of the push. Your settings (zone, hosts and secrets) are kept, because they aren't in src/.

To skip these steps next time, add .github/workflows/update.yml from camada-app/camada-cloudflare to your copy. Then go to Actions, pick Update Camada and choose Run workflow.

Uninstall

Do these in order:

  1. Delete the Worker: Workers & Pages, pick the Worker, Settings, Delete.
  2. Delete the rule: Security, WAF, Custom rules, camada:block v1, Delete. Delete only that rule, never the whole ruleset.
  3. Delete the list: Manage Account, Configurations, Lists, camada_block, Delete.

The order matters because the rule uses the list, and a running Worker would recreate both.

When to use an SDK instead

Use an SDK when you need:

  • Blocking on the first request, inline in your app.
  • Challenges (proof of work).
  • ASN, country, or path and header block rules (plus multi-condition or regex Skip rules).
  • App outcomes from track(), or the beacon.
  • A site that isn't on Cloudflare.

Pick yours on the frameworks page, or see Hono on Cloudflare Workers if your app is already a Worker. Don't feed one project from both an SDK and this Worker: every request would be counted twice.

Other SDK references: Hono on Workers · Python · Go SDK · PHP · Ruby · Java · .NET · all frameworks · in-app bot detection.