Self-Hosted Gateway
For partners who want full control over their bot protection layer, BotShield provides an open-source gateway template that you deploy on your own infrastructure. Same verification flow, fully customizable.The self-hosted gateway uses the same BotShield verification as the managed option. You still need an active BotShield account and gate credentials from your Partner Dashboard.
Why Self-Host?
The managed gateway is the fastest way to get protected — zero code, managed infrastructure. The self-hosted option is for teams that need:| Need | Self-Hosted Advantage |
|---|---|
| Path-based rules | Skip verification for API routes, static assets, health checks, webhooks |
| Custom branding | Match the verification page to your brand — colors, logo, copy |
| Your own infrastructure | Deploy on your Cloudflare account, or port to Vercel Edge, Deno Deploy, Fastly Compute, AWS CloudFront Functions |
| Audit and compliance | Full visibility into the proxy code — no hidden behavior, no data collection |
| Advanced routing | Rate limiting, geo-blocking, A/B testing, custom headers before or after verification |
Get the Template
The gateway template is available on GitHub. Clone it, configure it, deploy it.View on GitHub
Browse the source code, examples, and documentation
Download ZIP
Download the latest release as a ZIP archive
Quick Start
1. Clone the repository
2. Get your credentials
From your Partner Dashboard, navigate to Storefront Gate and note your:- Gate ID — identifies your gate configuration
- JWT Secret — the HS256 signing key for session tokens
3. Configure
Updatewrangler.toml with your settings:
4. Create a KV namespace
The gateway caches configuration in Cloudflare KV:id into wrangler.toml.
5. Deploy
Customization
Skip verification for specific paths
The template includes an example for bypassing the gate on certain routes — useful for API endpoints, static assets, health checks, and webhooks.worker/index.ts and call shouldBypass(url) before the session check to proxy matching requests without verification.
Custom verification page
The verification page is a single function inworker/gateHtml.ts. Replace the HTML and CSS to match your brand:
examples/custom-branding.ts.
Platform Compatibility
The gateway template is built for Cloudflare Workers but uses only standard Web APIs (fetch, crypto.subtle, Request, Response). It can be adapted to run on any edge platform that supports these APIs:
| Platform | Compatibility | Notes |
|---|---|---|
| Cloudflare Workers | Ready to deploy | Template default — uses wrangler CLI |
| Vercel Edge Functions | Portable | Replace KV with Vercel KV or Edge Config |
| Deno Deploy | Portable | Native Web API support, swap KV for Deno KV |
| Fastly Compute | Portable | Requires Fastly’s Wasm adapter for crypto.subtle |
| AWS CloudFront Functions | Partial | Limited crypto.subtle support — may need Lambda@Edge |
Architecture
Your edge worker handles everything. The only external dependency is the BotShield verification flow itself — when a visitor needs to verify, they’re directed toapp.botshield.ai and redirected back with a signed token.
Security
The self-hosted gateway inherits the same security model as the managed option:- HS256 JWT validation — tokens are signed with your secret and verified using the Web Crypto API
- HttpOnly, Secure cookies — session tokens can’t be accessed by client-side code
- Header sanitization — internal headers and the gate cookie are stripped before proxying to your origin
- No PII — no personal data is stored, logged, or transmitted
- Open source — inspect every line of code that runs in front of your traffic