Traffic Policy Security

Define per-agent request rules using CEL expressions. Deny suspicious requests, rate-limit by IP, inject headers, and strip sensitive data — all evaluated in real time on the server before requests reach the agent. No agent restarts needed.


How It Works

Policies sit in the server's middleware chain, after authentication and before dispatch. Rules fire top-to-bottom; each rule has one or more CEL expressions (all must match) and one or more actions that execute in order. The first terminal action (deny or forward) stops further evaluation.

HTTP Request ──► Auth ──► Traffic Policy Engine ──► Dispatch ──► Agent
                              │
                         ┌────┴────┐
                         │ Rule 1  │  expressions[] + actions[]
                         ├─────────┤
                         │ Rule 2  │  expressions[] + actions[]
                         ├─────────┤
                         │ Rule N  │  ...
                         └─────────┘

CEL Variables

Every rule expression has access to these variables:

VariableTypeDescription
req_pathstringRequest URL path (e.g. /api/users)
req_methodstringHTTP method (GET, POST, etc.)
req_headermap[string]stringRequest headers (first value per key)
conn_client_ipstringClient IP address

Actions

🚫 deny

Block the request with a configurable HTTP status code and body. Terminal — stops rule evaluation.

✅ forward

Explicitly allow the request and skip remaining rules. Terminal.

⏱️ rate-limit

Token-bucket rate limiting per dynamic key (CEL expression). Configurable rate and burst capacity.

➕ add-headers

Inject headers before forwarding to the agent. Useful for correlation IDs, internal routing, etc.

➖ remove-headers

Strip headers before forwarding. Remove sensitive data like auth tokens or internal metadata.

Policy Format

{
  "id": "my-agent",
  "rules": [
    {
      "expressions": [
        "req_method == 'DELETE'",
        "req_path.startsWith('/api/')"
      ],
      "actions": [
        {"type": "deny", "config": {"status_code": 403, "body": "DELETE not allowed"}}
      ]
    },
    {
      "expressions": ["req_path.startsWith('/api/')"],
      "actions": [
        {"type": "rate-limit", "config": {
          "key": "conn_client_ip",
          "rate": 10,
          "burst": 20
        }},
        {"type": "add-headers", "config": {
          "headers": {"X-Forwarded-For": "conn_client_ip"}
        }}
      ]
    }
  ]
}

API Endpoints

Manage policies via the admin API (port :8081):

MethodEndpointDescription
GET/api/v1/policiesList all policies
GET/api/v1/policies/{agentID}Get policy for an agent
PUT/api/v1/policies/{agentID}Create or update a policy
DELETE/api/v1/policies/{agentID}Delete a policy

Examples

Block all DELETE requests

curl -X PUT https://nfltr.xyz:8081/api/v1/policies/my-agent \
  -H "Content-Type: application/json" \
  -d '{
    "id": "my-agent",
    "rules": [{
      "expressions": ["req_method == '\''DELETE'\''"],
      "actions": [{"type": "deny", "config": {"status_code": 403, "body": "Forbidden"}}]
    }]
  }'

Rate-limit API by client IP

curl -X PUT https://nfltr.xyz:8081/api/v1/policies/my-agent \
  -H "Content-Type: application/json" \
  -d '{
    "id": "my-agent",
    "rules": [{
      "expressions": ["req_path.startsWith('\''/api/'\'')"],
      "actions": [{"type": "rate-limit", "config": {
        "key": "conn_client_ip", "rate": 10, "burst": 20
      }}]
    }]
  }'

Strip sensitive headers

curl -X PUT https://nfltr.xyz:8081/api/v1/policies/my-agent \
  -H "Content-Type: application/json" \
  -d '{
    "id": "my-agent",
    "rules": [{
      "expressions": ["true"],
      "actions": [{"type": "remove-headers", "config": {
        "headers": ["X-Internal-Token", "X-Debug-Info"]
      }}]
    }]
  }'
💡 MCP Integration

Policies can also be managed via the MCP gateway using list_policies, get_policy, set_policy, and delete_policy tools — enabling AI-driven policy management.

⚠️ Storage

Policies are stored in memory and do not persist across server restarts. Re-apply policies after restart or automate with your deployment pipeline.

Protect your tunnels with traffic policies

Rate-limit, filter, and manipulate requests before they reach your agent.

Download Agent CLI Reference →