Overview
Policies are security and behavior rules that execute before authentication and action execution. They are evaluated in the order they appear in the configuration array. If any policy blocks or challenges a request, processing stops immediately.
Available Policy Types
- waf - Web Application Firewall with ModSecurity-compatible rules and OWASP CRS
- rate_limiting - Token bucket and fixed window rate limiting, keyed by IP, API key, or expression
- ip_filter - IP address whitelisting and blacklisting by IP or CIDR range
- security_headers - Inject security headers (HSTS, CSP, X-Frame-Options, etc.)
- csrf - CSRF protection with double-submit cookie pattern
- ddos - DDoS detection with challenge-response mitigation
- request_limit - Request size, header count, and body size limits
- concurrent_limit - Cap in-flight (concurrent) requests per route, IP, or API key
- sri - Subresource integrity verification
- expression - Custom CEL or Lua expression policies
- request_validator - Validate request bodies against a JSON Schema before they reach the upstream
- openapi_validation - Reject requests that do not match a published OpenAPI 3.0 spec
- page_shield - Stamp a CSP header on every response and collect violation reports
- exposed_credentials - Detect known-leaked passwords on inbound Basic-auth and tag or block
- dlp - Data Loss Prevention scan over request URI and headers, with inline patterns and vendor catalogs
- ai_crawl_control - Emit HTTP 402 challenges to crawlers without a valid
Crawler-Paymenttoken - prompt_injection_v2 - Score inbound prompts with a heuristic detector and tag, block, or log
Example
Combine WAF and rate limiting policies:
proxy:
http_bind_port: 8080
origins:
"api.example.com":
action:
type: proxy
url: https://test.sbproxy.dev
policies:
- type: waf
owasp_crs:
enabled: true
paranoia_level: 1
- type: rate_limiting
requests_per_second: 100
burst: 200
key: ip
Test it:
curl -H "Host: api.example.com" http://localhost:8080/