GettingStarted
Doorman 2.0 introduces multi-provider WAF automation so you can manage Vercel and Cloudflare security policies from the same workflow. Use this guide to get set up today and prepare for the forthcoming Cloudflare release.
Installation
To get started with Vercel Doorman, first install it using your preferred package manager:
npm install vercel-doorman
Doorman 2.0 preview
Cloudflare WAF support ships with Doorman 2.0. Install the CLI today and you will be able to target --provider cloudflare as soon as the release is live.
Basic Usage
- Create or update configuration file:
Ensure you have a
vercel-firewall.config.jsonfile in your project root with the following structure:{ "projectId": "prj_", "teamId": "team_", "rules": [], "ips": [] }Replace
prj_andteam_with your actualprojectIdandteamId from Vercel.Cloudflare configuration (Doorman 2.0)
The upcoming release adds support for Cloudflare accounts and zones. You will be able to extend your config with provider-specific sections without changing the rest of your workflow. Stay tuned for the dedicated Cloudflare quickstart when 2.0 is live.
- Add firewall rules:
You can add rules in two ways:
- Using Templates:
Use the
templatecommand to add predefined rules:# List available templates npx vercel-doorman template # Add WordPress protection npx vercel-doorman template wordpress # Block AI bots npx vercel-doorman template ai-bots
- Manual Configuration:
Add rules directly to your config file following this structure:
{ "name": "Block API Access", "description": "Block access to API endpoints", "conditionGroup": [ { "conditions": [ { "type": "path", "op": "pre", "value": "/api" } ] } ], "action": { "mitigate": { "action": "deny", "rateLimit": { "requests": 100, "window": "1m" }, "actionDuration": "1h" } }, "active": true }
Rule Components:
- Condition Groups: Define when rules trigger (AND within groups, OR between groups)
- Conditions: Match criteria using
type,op, andvalue - Actions: Define response (
deny,challenge,rateLimit,rewrite) - Metadata: Rule information (
name,description,active)
For more examples and templates, visit our examples folder on GitHub.
- Using Templates:
- Sync your rules:
npx vercel-doorman sync --token YOUR_VERCEL_API_TOKEN
This will apply your firewall rules to your Vercel project. Replace
YOUR_VERCEL_API_TOKENwith your actual Vercel API token.Learn how to create and use a Vercel API token
Cloudflare sync (preview)
Doorman 2.0 adds
npx vercel-doorman sync --provider cloudflareso you can promote Cloudflare WAF changes alongside your Vercel updates. - Add script alias (optional):
To make it easier to run the sync command, add a script alias to your
package.jsonfile:"scripts": { ... other scripts ... "firewall:list": "vercel-doorman list", "firewall:download": "vercel-doorman download", "firewall:sync": "vercel-doorman sync", "firewall:validate": "vercel-doorman validate" }This will allow you to run
npm run firewall:syncto apply your firewall rules.
Common Rule Examples
Basic Protection
- ip-block.json - Block specific IP addresses
- path-protection.json - Secure specific URL paths
- geo-blocking.json - Country-based access control
- method-restriction.json - Limit HTTP methods
Advanced Security
- rate-limiting.json - Prevent abuse through rate limits
- redirect-rules.json - Traffic redirection examples
- challenge-rules.json - Bot prevention with challenges
- conditional-rules.json - Complex rule combinations
Specialized Rules
- user-agent-filtering.json - Filter by browser/client type
- header-based-rules.json - Rules based on HTTP headers
- mixed-rules.json - Multiple protection layers