Cloudflare Workers Integration
Score every visitor at Cloudflare's edge using ipinsights.io and act on the response in JavaScript.
Overview
Where the WAF integration
blocks IPs that are already on the public blocklist, this Worker performs a live lookup against
the ipinsights.io API for any request that isn't already cached — so you
catch IPs that have only just turned bad, and you can act on richer signals such as
is_tor, is_proxy and ASN.
Prerequisites
- Cloudflare account on any plan (Workers free tier is sufficient for < 100k req/day)
- Wrangler 3.x installed locally
- An ipinsights.io API key — your profile page
Step 1 — Scaffold the Worker
Step 2 — Worker Source
Replace src/index.js:
Step 3 — Deploy & Route
Step 4 — Verify
Lower the BLOCK_THRESHOLD temporarily to confirm your own IP gets a 403, then
restore it.
Notes
- Rate limits: the per-datacentre cache means even high-traffic sites typically issue < 1 lookup per unique IP per hour.
- Fail-open: if the lookup API is unreachable the Worker proxies the request unmodified. Consider Cloudflare Logpush so that failures are visible.
- Country / ASN policies: swap the
BLOCK_THRESHOLDcheck for a richer rule usingdata.country_code,data.asnordata.is_proxy.
API Key: Required — your key on your profile page. Register for free if needed.
Request Higher API Limit
Running a high-volume Cloudflare Workers deployment? If the default rate limit isn't enough for your environment, submit a request below and we'll review it.