Gateway

The Tetrapus Gateway is the public reverse proxy. It terminates TLS, looks up the right data plane for an incoming request (by Org slug or by JWT issuer), enforces the Org's pinned region, applies a per-tenant rate-limit, and forwards the request. The gateway is stateless; horizontally scale by adding replicas behind your load balancer.

Routing topology

graph LR CLIENT["Client"] -->|TLS| GW["Gateway"] GW -->|cache miss| CP["Control Plane<br/>/control/assignments"] GW -->|cache hit| ROUTE{"Route by slug<br/>or JWT iss"} ROUTE -->|acme| DPA["Data Plane A<br/>us-east-1"] ROUTE -->|globex| DPB["Data Plane B<br/>us-east-1"] ROUTE -->|initech| DPC["Data Plane C<br/>eu-west-1"]

Routing rules

  • Slug routingHost: acme.api.tetrapus.io → lookup slug=acme.
  • JWT iss routing — if no slug header, parse Authorization: Bearer … and route by the iss claim.
  • Region enforcement — if the gateway pod's region does not match the Org's region_code, return 421 Misdirected Request with the correct region in Location:.
  • Per-tenant rate-limit — token bucket keyed on Org id. Defaults set by plan tier; override via --rate-limit-rps.
  • Suspend / delete — suspended Orgs return 423 Locked; deleted return 410 Gone.

Configuration flags

Flag Env var Default Purpose
--bindDM_GATEWAY_BIND0.0.0.0:443Listen address for client traffic.
--upstream / --control-urlDM_GATEWAY_CONTROL_URLBase URL of the control plane.
--region-codeDM_GATEWAY_DEFAULT_REGIONus-east-1Region this gateway pod runs in.
--rate-limit-rpsDM_GATEWAY_RATE_LIMIT_RPSplan-defaultPer-Org token bucket refill rate.
--tls-certDM_GATEWAY_TLS_CERTPEM cert chain (omit if a sidecar terminates TLS).
--tls-keyDM_GATEWAY_TLS_KEYPEM private key.
--cache-ttlDM_GATEWAY_CACHE_TTL60Seconds the assignment cache holds an entry.

Sample invocation

Bash
tetrapus-gateway \
    --bind 0.0.0.0:443 \
    --control-url https://control.internal:9100 \
    --control-token "$(cat /etc/tetrapus/control.token)" \
    --region-code us-east-1 \
    --rate-limit-rps 500 \
    --tls-cert /etc/tetrapus/tls/fullchain.pem \
    --tls-key  /etc/tetrapus/tls/privkey.pem

Related

Questions?

Reach out for help with integration, deployment, or custom domain codecs.