Expand description
Configuration. Env-first so EdgeGuard drops into any PaaS that injects $PORT
with zero edits; an optional TOML file layers richer policy on top.
Structs§
- Access
Cfg - IP allow/deny lists, matched against the resolved client IP (the same IP rate limiting keys
on — so behind a trusted proxy, set
server.trust_forwarded_forfor this to see the real client). Both lists accept plain IPs (203.0.113.7,::1) and CIDR ranges (10.0.0.0/8,2001:db8::/32).denywins overallow; a non-emptyallowmeans “only these may connect”. Both empty (the default) = allow all. Compiled into acrate::access::AccessPolicy; an unparseable entry fails at startup/reload. - AcmeCfg
- Automatic certificate management (ACME / Let’s Encrypt) via the HTTP-01 challenge. The
obtained certificate is written to
TlsCfg::cert_path/key_pathand served by the TLS listener; a background task renews it before expiry. - AuthCfg
- Config
- Control
Plane Cfg - Managed-mode settings: when
enabled, the edge pulls its policy from a remote control plane (and hot-reloads it), reports metric deltas, and forwards CSP reports. The policy the control plane pushes is the policy subset (auth/ratelimit/validation/headers/waf) — the edge keeps its own localserver/tls. The edge token is a secret, so preferEDGEGUARD_CP_EDGE_TOKEN. - CorsCfg
- Cross-Origin Resource Sharing policy. A drop-in front door commonly sits in front of an app
whose browser frontend is served from a different origin (a separate static host, a
preview URL,
localhost:5173in dev); without CORS thosefetchcalls are blocked by the browser. Whenenabled, EdgeGuard answers preflightOPTIONSrequests itself (before auth — preflights carry no credentials) and adds the matchingAccess-Control-*headers to actual responses. Off by default: opening cross-origin access is a deliberate choice. Compiled into acrate::cors::CorsPolicy. - Headers
Cfg - JwtCfg
- JWT bearer-token verification. Either a symmetric
secret(HS*) or an asymmetric key (RS*/ES*/PS*) supplied as a staticpublic_key_pemor fetched fromjwks_url. - PerKey
Rate Limit - Per-principal rate limit (keyed by API-key id / JWT subject).
- Rate
Limit Cfg - Route
Rate Limit - A per-route rate-limit override (matched by path prefix).
- Server
Cfg - TlsCfg
- TLS termination. When
enabled, EdgeGuard serves HTTPS on the public port using a certificate either loaded fromcert_path/key_pathor obtained automatically via ACME. All-default fields (disabled, empty paths, default ACME) soDefaultis derivable. - Upstream
Route - A per-path-prefix upstream override (a
[[upstreams]]entry). Requests whose path starts withpathare forwarded totargetinstead of the defaultserver.upstream; the longest matching prefix wins. This is deliberately a static prefix map for the common “static frontend +/apibackend” shape — not a gateway: no service discovery, load balancing, health-based routing, or request rewriting (the path is forwarded unchanged). For those, put EdgeGuard behind a real gateway/mesh. - Validation
Cfg - WafCfg
- WAF-lite input inspection (Phase 4 / v2). Screens a request for common attack signatures
before it is forwarded, using built-in heuristic rulesets (SQLi/XSS/path-traversal) plus
any operator-defined deny patterns. Disabled by default — these are heuristics, so the
intended rollout is
report(log + count matches without blocking) until the operator is confident, thenblock(return403). Compiled into acrate::waf::WafEngine. - WafRule
- A single operator-defined WAF deny pattern (a
[[waf.rules]]entry).
Functions§
- parse_
duration - Parse a timeout like “30s”, “500ms”, “2m”, or a bare number of seconds (“45”). “0” yields a zero duration, which callers treat as “disabled”.
- parse_
rate - Parse a rate like “60/min” into (count, period).
- parse_
size - Parse a human size like “2MiB”, “512KB”, “1048576” into bytes.