Limits and Shaping
WAF rules, rate limits, traffic shapers, and cache rules are global public proxy controls.
What It Is
These controls protect, slow, or cache public traffic around route/target selection.
| Layer | Runs | Typical use |
|---|---|---|
| WAF | Before rate limits | Block, captcha, or queue traffic by HTTP match rules. |
| Rate limits | Before traffic shaping | Reject repeated requests with 429. |
| Traffic shaping | Before route/target forwarding | Slow upload and download streams without rejecting the request. |
| Cache | After route/target selection | Serve eligible public proxy assets from proxy storage. |
When It Matters
Use these controls when protecting login endpoints, controlling API budgets, slowing large transfers, queuing short traffic surges, or caching public static assets.
Runtime Behavior
Every public request passes through these layers in order. A request stopped at an earlier layer never reaches later ones.
Evaluation order:
- ACME HTTP challenge bypass
- Reserved WAF endpoints
- WAF rules
- Rate limits
- Traffic shapers
- Route and target selection
- Cache rule evaluation and lookup
- Origin forwarding or cached response
Policy matching uses request-only CEL match_rule expressions for method, protocol, host, path, remote IP/CIDR, headers, cookies, and query parameters. See CEL Policy Matching for the shared matcher syntax, validation rules, and examples. Legacy match is removed from the public API; existing stored legacy rows are migrated automatically. If no key parts are configured, remote IP is used.
Cache route_ids and target_ids remain separate filters evaluated after route/target selection.
Traffic shaping uses byte-per-second token buckets. per_key shares a bucket for requests with the same key; per_request gives each request its own bucket.
Cache rules store eligible public GET/HEAD responses for proxy targets after route/target selection. Cache hits still pass through WAF, rate limits, and traffic shaping first.


Common Mistakes
- Using remote IP as the only key when p2pstream sits behind another reverse proxy.
- Creating broad rules with low priority numbers that catch unrelated traffic.
- Expecting cache hits to bypass rate limits or WAF.
- Allowing cookie-bearing cache requests on broad dynamic paths instead of precise static asset paths.