Docs menu

Operate

Edge protection

Rate limits, connection caps, IP allow and deny lists, bot blocking and body size limits, enforced at the router before requests reach your app.

Explain it

Edge protection stops floods of traffic, scrapers and unwanted callers before they reach your app, so they don't use up its capacity or your credit.

How to do it: open an app, go to its Settings tab, and pick a preset under Edge protection (for example a limit on requests per visitor). Presets are made to protect a public app without getting in real visitors' way.

"Turn on basic protection against floods for my API."

Edge rules stop floods, scrapers and unwanted callers at CLI's router, before they use your app's CPU or your credit.

RuleWhat it does
rateLimitRequests a second per visitor address, with a burst allowance ({"average": 20, "burst": 60})
maxInFlightRequests in progress at once per visitor address
allowIpsOnly these addresses or CIDR ranges may reach the app
denyIpsThese may not
blockBotsBlocks scrapers, vulnerability scanners and AI crawlers by user agent, plus requests with no user agent. Search engines still get in.
blockUserAgentsYour own list of user-agent fragments to refuse (case-insensitive, at least 3 characters each)
maxBodyKbThe largest request body accepted

Presets

Start from one and adjust:

  • standard: 20 requests a second (burst 60), 50 at once, bots blocked, 10 MB bodies. Good for sites and apps people use.
  • api: 10 a second (burst 30), 20 at once, 1 MB bodies.
  • strict: 5 a second (burst 10), 10 at once, bots blocked, 512 KB bodies.
API
PUT /v1/services/:id/edge {"preset": "standard", "denyIps": ["203.0.113.0/24"]}

Each PUT replaces the rules. Send {} to remove them all.

How it's enforced

Rate limits, connection caps, allow-lists and body sizes run in the router itself. They take effect after a quick restart of the running version, which CLI starts for you; there's no downtime. Deny-lists and bot blocking go through a check CLI answers for every request, and apply within seconds. Blocked visitors get 403 with error code EDGE_BLOCKED. Requests over the rate limit get 429.

GET /v1/services/:id/edge shows how many requests were blocked in the last 24 hours, by reason.

Behind a CDN

If the operator runs Cloudflare (or another proxy) in front of CLI, the address the router sees is the proxy's. The deny-list check uses CF-Connecting-IP when it's present. For the router's own per-address limits, the operator should set Traefik's forwarded-headers trust for the proxy's ranges. Large attacks are best absorbed at the CDN; edge rules are the layer behind it.

Agents use cli_edge.