Edge Rules
Define custom routing, request modification, blocking, redirection, or caching behavior using powerful conditional matching rules executed at the edge.
Edge Rule Structure
An edge rule consists of one or more conditions, an action, and optional config arguments. Rules run sequentially based on their priority.
Conditions & Fields
Conditions specify what request properties trigger the action. Available condition fields include:
| Field | Operators | Description |
|---|---|---|
| path | equals, starts_with, ends_with, contains, regex | The request URL path (e.g. `/v1/admin`) |
| ip | equals, in_cidr, not_in_cidr | The client IP address (e.g. `203.0.113.1` or `10.0.0.0/8`) |
| country | equals, in_list | ISO country code of client location (e.g. `US`, `GB`) |
| method | equals, in_list | HTTP method (e.g. `POST`, `DELETE`) |
| header | equals, starts_with, exists | Matches against specific request header names and values |
Actions & Gating
Different actions are supported depending on your plan. Lower tier plans support basic block/allow actions, while features like rewriting and header injection require Starter or Pro.
| Action | Plan Requirement | actionConfig structure |
|---|---|---|
| allow | All | none |
| block | All | none |
| challenge | All | none |
| redirect | Starter+ | { "url": "https://...", "statusCode": 301 } |
| add_header | Starter+ | { "name": "X-Custom", "value": "value" } |
| rate_limit | Pro+ | { "requestsPerMinute": 60 } |
| rewrite | Pro+ | { "path": "/new-path" } |
Dashboard Setup & Configuration
You can create and manage Edge Rules directly inside the EdgeWrap Dashboard:
- Navigate to your project in the dashboard at
https://app.edgewrap.pro. - Go to the Security page and select the Edge Rules tab.
- Click the Add Rule button.
- Enter a descriptive name and priority order (rules with lower priority numbers run first).
- Add one or more conditions (e.g. target path, country, method, header value) using operators.
- Select the action to take when the conditions are met (such as redirect, add_header, rate_limit, or block).
- Click Save Rule.
API Configuration
Alternatively, you can manage your Edge Rules programmatically by calling the rules API:
Create an Edge Rule via API
curl -X POST https://server.edgewrap.pro/v1/projects/prj_01jxyz/rules \
-H "Authorization: Bearer <your_session_token>" \
-H "Content-Type: application/json" \
-d '{
"name": "Block Admin Except Corporate IP",
"priority": 10,
"conditions": [
{ "field": "path", "op": "starts_with", "value": "/admin" },
{ "field": "ip", "op": "not_in_cidr", "value": "198.51.100.0/22" }
],
"action": "challenge",
"actionConfig": {},
"isEnabled": true
}'Tip: Rules are cached at edge nodes for fast processing. Modifications take about 10–15 seconds to sync globally to all edge locations.