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:

FieldOperatorsDescription
pathequals, starts_with, ends_with, contains, regexThe request URL path (e.g. `/v1/admin`)
ipequals, in_cidr, not_in_cidrThe client IP address (e.g. `203.0.113.1` or `10.0.0.0/8`)
countryequals, in_listISO country code of client location (e.g. `US`, `GB`)
methodequals, in_listHTTP method (e.g. `POST`, `DELETE`)
headerequals, starts_with, existsMatches 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.

ActionPlan RequirementactionConfig structure
allowAllnone
blockAllnone
challengeAllnone
redirectStarter+{ "url": "https://...", "statusCode": 301 }
add_headerStarter+{ "name": "X-Custom", "value": "value" }
rate_limitPro+{ "requestsPerMinute": 60 }
rewritePro+{ "path": "/new-path" }

Dashboard Setup & Configuration

You can create and manage Edge Rules directly inside the EdgeWrap Dashboard:

  1. Navigate to your project in the dashboard at https://app.edgewrap.pro.
  2. Go to the Security page and select the Edge Rules tab.
  3. Click the Add Rule button.
  4. Enter a descriptive name and priority order (rules with lower priority numbers run first).
  5. Add one or more conditions (e.g. target path, country, method, header value) using operators.
  6. Select the action to take when the conditions are met (such as redirect, add_header, rate_limit, or block).
  7. 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.