Gateway configuration
Every setting the gateway reads from its environment when it starts, with its default, the addresses it serves for health and logging, and what it logs and traces.
Available, with limitsAPI
The gateway is configured entirely by environment variables, read once when it starts. Five are required; every other one has a default that suits a gateway beside one API. To change a setting, restart the gateway with the new value.
The gateway’s image isn’t published yet: ask your Cvyūh contact for it. The settings below are the ones it reads today.
A gateway missing a required setting, with a refresh interval of 3 seconds or less, or with a value that doesn’t parse stops at once and says which one.
Before you begin
Section titled “Before you begin”- The gateway’s client active in the realm, with the public half of its key: see
Run the gateway. That’s done by a realm administrator in a group
holding
RealmOwner, with the API. - Access to where the gateway runs, to set its environment and mount its key file.
Required
Section titled “Required”| Variable | What it sets | Example |
|---|---|---|
ISSUER | The realm’s issuer. Every token must carry it as iss, and the gateway reads the realm’s keys, policies and revocations at its origin | https://foobar.cvyuh.com/oauth2 |
JWT_AUDIENCE | Your API’s audience. Every token must name it in aud, and the gateway’s resource metadata is published under it | https://api.example.com |
CLIENT_ID | The gateway’s own client in the realm, usually floor | floor |
CLIENT_KEY | The path of the gateway’s private key, a P-256 key in PEM. The client’s public key in the realm is its other half | /etc/gateway/key.pem |
POLICY_SET | The policy set the gateway enforces | default |
Where it listens and forwards
Section titled “Where it listens and forwards”| Variable | Default | What it sets |
|---|---|---|
LISTEN | 0.0.0.0:8080 | Where callers reach the gateway, on plain HTTP/1.1: the inline proxy and the ext_authz check. Put your TLS front end before it |
BACKEND | http://127.0.0.1:8801 | Your API’s own address, where allowed requests go. Requests are decided on this host and port. One per gateway |
ADMIN_LISTEN | 127.0.0.1:8802 | Where health probes and log levels are served: see Health and logging |
AM_URL | The issuer’s origin | Where the realm is reached, when not at the issuer’s own address, such as through a private network. Every call still names the issuer’s host |
CA_FILE | None | A certificate bundle to trust beside the public authorities, when the realm’s certificate comes from a private one |
How current it stays
Section titled “How current it stays”| Variable | Default | What it sets |
|---|---|---|
JWKS_REFRESH | 300 | Seconds between fetches of the realm’s signing keys. A token signed with a key the gateway hasn’t seen makes it fetch them at once, at most once every 10 seconds |
POLICY_REFRESH | 60 | Seconds between fetches of the policy set |
BLACKLIST_REFRESH | 10 | The revocation poll interval: seconds between polls of the revocation feed. Three missed in a row and the gateway fails closed |
TOKEN_REFRESH_MARGIN | 60 | Seconds before the gateway’s own token expires that it gets a new one |
Each interval must be longer than 3 seconds, the most a single fetch may take. See How fast revocation takes effect for what a shorter revocation poll interval buys.
Tokens and callers
Section titled “Tokens and callers”| Variable | Default | What it sets |
|---|---|---|
SCOPES | None | Comma-separated scopes the resource metadata names as scopes_supported, for clients to ask for |
DPOP_REQUIRED | false | Refuse every token not bound to a key: see Bound tokens at the gateway |
DPOP_NONCE_KEY | None | The path of a file of random bytes nonces are made with, such as one made by openssl rand 32 > nonce.key. Set, every proof must carry a nonce the gateway issued. Give every replica the same file |
PUBLIC_ORIGIN | The audience’s origin | The scheme and host clients address the API at, when it isn’t the audience’s. A proof names the address the client used |
MTLS_FROM_FACE | false | The forwarded-certificate setting: read the client certificate your TLS front end forwards in x-forwarded-client-cert, for certificate-bound tokens. Set it only where every request comes through that front end |
UPSTREAM_AUDIENCE | None | Your API’s own resource identifier. Set, every allowed call goes on under a fresh token meant for it alone: see Token swap |
MCP servers
Section titled “MCP servers”| Variable | Default | What it sets |
|---|---|---|
MCP_PATHS | None | Comma-separated paths an MCP server answers at, such as /mcp. A POST to one is decided as the MCP call it makes: see MCP tool calls |
MCP_MIRRORED_DOOR | false | The headers-only setting: decide an ext_authz check that carries no body on its MCP headers alone. Set it only when your proxy has already held the headers to the body |
Logging
Section titled “Logging”| Variable | Default | What it sets |
|---|---|---|
APP_LOG | info | The level the gateway’s own log starts at: off, error, warn, info, debug or trace. Change it while the gateway runs at /admin/log |
Names that will change
Section titled “Names that will change”Some variables carry names that will change, with the names above kept working beside the new ones:
| Today | Will also be read as |
|---|---|
AM_URL | REALM_URL |
BLACKLIST_REFRESH | REVOCATIONS_REFRESH |
MTLS_FROM_FACE | MTLS_FORWARDED_CERT |
MCP_MIRRORED_DOOR | MCP_HEADERS_ONLY |
APP_LOG | LOG_LEVEL |
Until then, only the names in the tables above are read.
Limits and defaults
Section titled “Limits and defaults”| What | Default | Can it change? |
|---|---|---|
| Connecting to your API | 5 seconds | No |
| Your API’s answer | 60 seconds, then 504 | No |
| Retries of a failed call to your API | None | No |
| Request bodies | 1 MiB on an MCP path; no limit elsewhere | No: cap sizes at your TLS front end |
| Any one fetch from the realm, or a decision asked of it | 3 seconds | No |
| Refresh intervals | Longer than 3 seconds | As above |
| APIs per gateway | One | No |
Health and logging
Section titled “Health and logging”The gateway serves these on ADMIN_LISTEN, apart from the traffic it guards. Keep that address private.
| Method | Path | What it does |
|---|---|---|
GET | /health/live | Answers 200 while the process runs |
GET | /health/ready | Answers 200 while it takes requests, and 503 once it’s stopping |
GET | /health/startup | Answers 200 once it has started |
GET | /health/backends | Whether the realm’s key set can be reached, as JSON |
GET | /admin/log | The log levels in force |
PUT | /admin/log?level=<level> | Change the gateway’s log level while it runs: off, error, warn, info, debug or trace |
PUT | /admin/log/filter | Replace the whole log filter, when Cvyūh support asks you to |
On stop, the gateway finishes the requests in flight before it exits: see Run it in production.
Logs and tracing
Section titled “Logs and tracing”The gateway writes its log to standard output, one JSON object per line. At the default level, each request writes:
- One line as it arrives, with its method, its path and its trace id.
- One line as it’s answered, with its status and how long it took, in milliseconds. A
5xxanswer is logged as an error. - One warning line for each refusal, with the path, the caller (
agent, the token’ssub) when the token verified, and why: the policy reason (such aspolicy_deniedorno_matching_policy), a revoked token or agent, a proof that failed, or a missing or invalid token.
At debug, allows are logged too, with the caller and the path, and so is each decision the gateway asks the realm
for, with its verdict.
Tracing. Each request continues the W3C trace context its caller sent in traceparent and baggage, or starts a
new trace. The gateway passes it on to your API, and puts traceparent on its answer, so one trace id follows a call
from the client through the gateway to your API. The trace id is on every line the request logs.
Your log collector keeps the gateway’s decisions: they aren’t on the realm’s audit trail yet. See What’s next for protecting APIs.
An example
Section titled “An example”A gateway in front of an API at http://127.0.0.1:8801, for the realm foobar, with token swap and nonces on:
docker run -d --name gateway --network host \ -v "$PWD/gateway-key.pem:/etc/gateway/key.pem:ro" \ -v "$PWD/nonce.key:/etc/gateway/nonce.key:ro" \ -e ISSUER=https://foobar.cvyuh.com/oauth2 \ -e JWT_AUDIENCE=https://api.example.com \ -e CLIENT_ID=floor \ -e CLIENT_KEY=/etc/gateway/key.pem \ -e POLICY_SET=default \ -e BACKEND=http://127.0.0.1:8801 \ -e UPSTREAM_AUDIENCE=https://orders.internal.example.com \ -e DPOP_NONCE_KEY=/etc/gateway/nonce.key \ -e SCOPES=invoices:read,invoices:write \ "$GATEWAY_IMAGE"$GATEWAY_IMAGE is the image your Cvyūh contact gave you.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Cause | Fix |
|---|---|---|
| The gateway exits at once | A required variable is missing, an interval is 3 seconds or less, or a value doesn’t parse | Its last words name the variable and why |
The gateway exits naming CA_FILE or DPOP_NONCE_KEY | The file can’t be read, or is empty | Mount the file at the path you named |
| The gateway runs but refuses everything | It can’t sign in to the realm or reach it | See Troubleshooting |
Related
Section titled “Related”- Run the gateway: what each request goes through.
- Run it in production: replicas, probes and stopping.
- Get started with Gateway: the settings in use, end to end.
- Gateway API: every endpoint the gateway and the realm serve for it.