Skip to content
GatewayMarkdown

Run it in production

Where the gateway's image comes from, how to run several replicas, which health probes to wire up, how it stops, and what keeps working while the realm can't be reached.

Available, with limitsAPI

In production the gateway runs as a few identical replicas behind your TLS front end, each next to the API it guards. Each replica decides on its own from its copy of the realm’s keys, policies and revocations, so replicas need nothing from each other except one shared file, and a short outage of the realm doesn’t stop your API.

The gateway’s image isn’t published yet: ask your Cvyūh contact for it, and for each update. There’s no packaged deployment, such as a chart, yet: run the image the way you run your other containers.

  • The gateway running in front of one API, as in Get started with Gateway, with its client active in the realm. Changing the client takes a realm administrator in a group holding RealmOwner, with the API.
  • A TLS front end, such as your load balancer or ingress, that ends TLS and forwards plain HTTP/1.1 to the gateway.
  • A way to mount files into each replica: the gateway’s private key, and the nonce key below.
callers ─TLS─▶ TLS front end ─HTTP/1.1─▶ gateway replicas ─▶ your API
│
└─▶ the realm

Every replica reaches the realm at https://foobar.cvyuh.com and your API at BACKEND. Nothing reaches a replica but your front end, and nothing reaches your API but the gateway.

Replicas are interchangeable: run as many as your traffic needs, behind your front end’s load balancing, with the same settings. Two things must be the same on every replica:

  • The gateway’s key (CLIENT_KEY). Every replica signs in as the same client.
  • The nonce key (DPOP_NONCE_KEY), when you require nonces for bound tokens. Give every replica the same key file, and a nonce one replica gave is good at the others. Make it once with openssl rand 32 > nonce.key and keep it with your other secrets.

Keep each client on one replica, with session affinity at your front end. A replica refuses a key-bound token’s proof the second time it sees it, and keeping a client on one replica holds every proof it sends to that rule.

Each replica polls the realm on its own, so each learns of a policy change or a revocation within one of its own intervals.

Each replica keeps the last good copy of everything it holds:

What it holdsWhile the realm is unreachable
The realm’s keysKept. Tokens keep verifying
PoliciesKept. Requests keep being decided on the last policies it fetched
RevocationsKept for three poll intervals (30 seconds by default), then every request with a token is refused 503 revocations_stale until a poll lands
A decision only the realm can makeRefused 403 upstream_unavailable at once

So a realm outage of under half a minute goes unnoticed by callers, except for policies about groups. Past that, the gateway refuses rather than let through a token it can’t vouch for: see Fails closed.

The gateway answers its probes on ADMIN_LISTEN (127.0.0.1:8802 by default), apart from the traffic it guards. Set ADMIN_LISTEN=0.0.0.0:8802 where your orchestrator probes from outside the container, and keep that port private.

ProbePathAnswers 200Wire it as
Liveness/health/liveWhile the process runsRestart the replica when it fails
Readiness/health/readyWhile it takes requests; 503 once it’s stoppingSend traffic only while it passes
Startup/health/startupOnce it has made its first try at the realm’s keys, policies and revocationsHold the other probes until it passes

/health/backends says, as JSON, whether the realm’s key set can be reached: use it on a dashboard, not as a probe.

A replica that starts while the realm is unreachable still passes its probes, and refuses every request until its first policies and revocations arrive. Watch for 503 revocations_stale and 403 no_policies_loaded after a rollout, and the log line that says why the first load failed.

On a stop signal, a replica fails readiness at once and keeps serving for 5 seconds, while your front end stops sending to it. It then finishes the requests in flight, for up to 10 seconds, and exits. Give each replica a stop grace of at least 15 seconds, so no request is cut off in a rollout.

Roll replicas one at a time: start the new one, wait for its startup probe, then stop an old one. Replicas of two versions decide the same requests the same way, since every replica reads the same policies.

  1. Mount the same two key files into every replica: the gateway’s private key at CLIENT_KEY, and, if you require nonces, the nonce key at DPOP_NONCE_KEY.
  2. Give every replica the same settings: see Gateway configuration.
  3. Wire the probes as in the table above, and a stop grace of at least 15 seconds.
  4. Point your TLS front end at the replicas, and close every other way to your API.
  5. Collect each replica’s log, which holds its decisions: see Logs and tracing.
WhatDefaultCan it change?
Revocations kept while polls failThree poll intervals: 30 secondsThrough the revocation poll interval, longer than 3 seconds
Stop: serving after readiness fails5 secondsNo
Stop: finishing requests in flightUp to 10 secondsNo
A decision asked of the realm3 secondsNo
Gateways per APIOne API per gateway, any number of replicas—

The rest of the gateway’s limits are on Run the gateway.

SymptomCauseFix
A client meets 401 use_dpop_nonce on most requestsThe replicas have different nonce keys, so a nonce from one is refused at the nextMount the same DPOP_NONCE_KEY file on every replica
After a rollout, every request is refused for a whileThe new replicas started before they could reach the realmCheck the log for why the first load failed; the replica recovers at its next good poll
Requests are cut off during a rolloutThe stop grace is shorter than 15 secondsRaise it