Env-var reference
Every `<PREFIX>_*` environment variable, by namespace — the dual-path rule means each one also has a pinned-struct field.
Every framework module reads its config from a namespaced env prefix and
from a pinned struct — the framework-wide dual-path rule
(Pinning a config). The variable name is
<PREFIX>_<NAMESPACE>__<KEY> (double underscore between namespace and key).
This page lists the variables; each maps one-to-one to a field on the module’s
config struct, so anything here is also settable in code. Exported into the real
environment, one works even when the app pins its neighbours in module.rs,
field by field; written in a .env file, it reaches no config whose namespace
the app pins in code at all, and the boot names it as shadowed.
NESTRS is the default prefix. An app that declared its own
(Your own prefix) reads every name below
with that prefix instead — ACME_HTTP__PORT, ACME_LOG_FORMAT — and the
NESTRS_ spellings resolve nothing.
Every namespaced variable can also be given as a file.
<PREFIX>_<NAMESPACE>__<KEY>_FILE names a file whose content is the value — the
form a mounted secret takes, read the same way for every key.
The tables below name the _FILE spelling only where a key is usually given
that way.
Each part of a name is read, never chosen: the namespace is the path of the
crate that parses it, a named instance inserts its name after the vendor, and
every TLS client reads the same three keys, TLS_CA_CERT, TLS_CERT and
TLS_KEY (namespaces, instances and TLS keys).
Logging and OpenTelemetry
Section titled “Logging and OpenTelemetry”The console’s RUST_LOG, <PREFIX>_LOG_FORMAT and <PREFIX>_LOG_SOURCE_LOCATION,
and the specification’s OTEL_*, belong to no namespace:
logging and telemetry variables.
http — <PREFIX>_HTTP__*
Section titled “http — <PREFIX>_HTTP__*”| Key | Meaning |
|---|---|
HOST |
listen address (default 0.0.0.0) |
PORT |
listen port |
GLOBAL_PREFIX |
path prefix for every route (unset ⇒ none). One literal path: template syntax ({ }) or what the router reads as a parameter (: * <) fails the boot |
MAX_BODY_BYTES |
request body cap, counted as the body is read — by its extractor, a guard or a global pipe, after routing and the guards; past it the request is answered 413, and a declared Content-Length past it is refused unread — default 2 MiB; whole numbers from 1 to 1099511627776 (a tebibyte), refused outside |
MAX_CONCURRENT_CONNECTIONS |
connections served at once, an upgraded socket included until it closes — default 10000; whole numbers from 1 to 1048576, refused outside. Past it a new connection waits — the next one held by the server, the rest in the listen backlog — and one warn names the variable: see Connections |
HEADER_READ_TIMEOUT_SECS |
how long a connection has for its first request head, counted from accept with a TLS handshake inside it, and on HTTP/1 a later head from its first byte — default 30; whole seconds from 1 to 300, refused outside, 0 included. Past it the connection is closed: see Connection deadlines |
BODY_READ_TIMEOUT_SECS |
how long a request body may go without a byte once something reads it — default 10; whole seconds from 1 to 3600, refused outside, 0 included. Past it the request is answered 408, closing an HTTP/1 connection; on HTTP/2 that stream alone ends. Keep it under REQUEST_TIMEOUT_SECS, which counts from the request’s arrival: a body that stops within that timeout’s last gap is answered its 503 first, and at or past it every stalled body is, which one warn says at boot |
IDLE_TIMEOUT_SECS |
how long a kept-alive connection waits for its next request — default 75; whole seconds from 1 to 3600, refused outside, 0 included. Past it an HTTP/1 connection is closed and an HTTP/2 one sent GOAWAY; behind a load balancer, keep it above the balancer’s own idle timeout |
SEND_TIMEOUT_SECS |
how long a write waits on a peer that takes nothing, counted from the moment it starts waiting — default 60; whole seconds from 1 to 3600, refused outside, 0 included. Past it the connection is dropped, an event stream or a WebSocket included, and on HTTP/2 a stream the peer grants no window is reset |
REQUEST_TIMEOUT_SECS |
per-request timeout, counted from the request’s arrival, its body’s reading included — default 20, the shutdown window’s own; whole seconds from 1 to 3600, or 0 ⇒ no timeout. An overrun answers 503 with a Retry-After, not 504: this transport is the origin, not a gateway. A timeout past SHUTDOWN_TIMEOUT_SECS, or 0, files one warn at boot |
SHUTDOWN_TIMEOUT_SECS |
how long open connections may finish after a shutdown signal — default 20, so the window, the half second what it stopped takes to unwind, the shutdown hooks’ 5 s, OpenTelemetry’s 3 s flush and the console’s 1 s end inside the 30 s a Kubernetes pod gets before SIGKILL; whole seconds from 1 to 3600, refused outside, and 0 is refused rather than read as off. What is still open when it closes is cut — a running request goes unanswered, a download is cut — and one warn counts it. What has no end of its own — an event stream, a gateway’s WebSocket, a graphql-ws socket — ends at the signal instead: see Shutdown |
SECURITY_HEADERS_ENABLED |
the switch for the secure-by-default response headers, true by default |
SECURITY_HEADERS_HSTS · SECURITY_HEADERS_FRAME_OPTIONS · SECURITY_HEADERS_CONTENT_TYPE_OPTIONS |
individual security-header controls — each key is its field’s name after SECURITY_HEADERS_ |
SECURITY_HEADERS_REFERRER_POLICY · SECURITY_HEADERS_CROSS_ORIGIN_OPENER_POLICY · SECURITY_HEADERS_CROSS_ORIGIN_RESOURCE_POLICY |
the rest of the default-on set — strict-origin-when-cross-origin, same-origin, same-origin; off drops one, a blank value fails the boot, and an empty one keeps the default |
SECURITY_HEADERS_CONTENT_SECURITY_POLICY · SECURITY_HEADERS_CROSS_ORIGIN_EMBEDDER_POLICY · SECURITY_HEADERS_PERMISSIONS_POLICY |
settable, off by default — each governs a document whose sources the framework cannot speak for; see HTTP configuration |
SERVER_HEADER |
send Server: nestrs/<version>, false by default |
TLS_CERT / TLS_KEY |
PEM cert + key for HTTPS (inline); TLS_CERT_FILE / TLS_KEY_FILE read from a path instead. One half without the other fails the boot, and so do both spellings of one half in the same tier. Unset ⇒ plain HTTP |
TLS_RELOAD_SECS |
how often a file-sourced pair is re-read, so a renewal swaps in without a restart — default 60; from 1 to 86400 (a day), or 0 disables |
VERSIONING |
how a caller selects an API version — uri (default), header, media_type |
VERSION_HEADER |
the header the header strategy reads — default X-API-Version; a value that is no HTTP header name fails the boot, set or pinned |
DEFAULT_VERSION |
the version served to a caller that states none; unset ⇒ the unversioned routes |
CORS_ORIGINS |
comma-separated allowed origins, each scheme://host[:port] as a browser sends it — no path or trailing /, an internationalized host in its xn-- form — or *; compared as origins (scheme and host without case, the default port implied). null, or an entry that is no origin, fails the boot, named by its place. Unset ⇒ no CORS layer. Also the browser origins that may open a WebSocket or GraphQL socket and call MCP: unset, the server’s own alone; set, those listed alone, the server’s own included only when listed |
CORS_METHODS |
comma-separated allowed request methods; unset ⇒ the methods the routes serve and GET, HEAD, POST, or every method a page may send — PUT, DELETE, PATCH and OPTIONS too — once a mount answers any method itself, as /mcp does; CONNECT, TRACE or TRACK fails the boot |
CORS_HEADERS |
comma-separated allowed request headers |
CORS_EXPOSED_HEADERS |
comma-separated response headers exposed to the browser, beside Link, Location and Retry-After, always exposed |
CORS_CREDENTIALS |
allow credentialed requests — default false |
CORS_MAX_AGE_SECS |
preflight cache lifetime — whole seconds from 1 to 86400 (a day, every browser’s cap or more), or 0 ⇒ none; unset ⇒ no Access-Control-Max-Age |
COMPRESSION |
negotiate response compression from Accept-Encoding — default false (leave it to the proxy unless the app terminates responses) |
SSE_MAX_CONNECTION_SECS |
how long an #[sse] stream may stay open before the server ends it and the client reconnects — default 14400 (4 h); from 1 to 86400 (a day), or 0 ⇒ unlimited. A security control: the stream authenticates once, at the request |
SSE_KEEP_ALIVE_SECS |
keep-alive comment interval on an #[sse] stream, so an idle feed is not dropped by an intermediary — default 15; from 1 to 3600, or 0 ⇒ none sent |
ACCESS_LOG |
emit one access-log event per request on nest_rs::operation — default true. Owned by the HTTP transport, so it needs no observability crate; trace_id joins the line only when one is mounted |
TRUSTED_PROXIES |
comma-separated reverse-proxy addresses and CIDR ranges (10.0.0.1,10.0.0.0/8) whose Forwarded (RFC 7239) / X-Forwarded-For / X-Real-IP / traceparent / X-Request-Id are believed. Empty (the default) ⇒ none is read, every caller is its transport peer, and every inbound trace is restarted. Shared by ClientIp, the throttler, the trace context and the browser-origin check, which reads Forwarded / X-Forwarded-Proto / X-Forwarded-Host for the origin the browser was on; an entry that is neither, a /0, a range with address bits set past its prefix, or ranges holding between them every address of a family a caller connects from (0.0.0.0/1,128.0.0.0/1, or 0.0.0.0/1,128.0.0.0/2,192.0.0.0/3, short only of multicast and reserved space) abort the boot |
seaorm — <PREFIX>_SEAORM__*
Section titled “seaorm — <PREFIX>_SEAORM__*”The one pool every SeaORM binding shares, opened by SeaOrmModule,
on Postgres — the one engine the framework builds sea-orm with.
| Key | Meaning |
|---|---|
URL |
database connection string, postgres:// or postgresql://; any other scheme fails the boot without quoting it. TLS is verified or off: with no sslmode the connection asks for verify-full, the server’s certificate checked against the system’s authorities — or the file sslrootcert names; libpq’s sslrootcert=system is the system’s too — and its name against the host; sslmode=disable is plaintext, written where it is meant, or libpq’s PGSSLMODE=disable beside a URL naming no mode, and a deployed profile says so once at warn when the server is off this machine. allow, prefer, require and verify-ca, which encrypt without that check or may, fail the boot naming this variable, or PGSSLMODE where it set one. Every connection the framework opens holds to it — the pool, connect_from_env, EphemeralDatabase — through SeaOrmConfig::connect_options. libpq’s PGSSLROOTCERT names the authority beside a URL naming no sslrootcert, in place of the system’s, as libpq reads it; a certificate file one of them names that this process cannot read fails the boot at once, naming where it is set. The URL is read at the start; the files its sslrootcert, sslcert and sslkey name are read at each connection the pool opens, so a renewed one reaches every connection opened after it |
MAX_CONNECTIONS |
pool maximum connections — default 10, sqlx’s; whole numbers from 1 to 262143, what a Postgres server’s own max_connections goes up to, refused outside |
MIN_CONNECTIONS |
pool minimum idle connections — default 0, sqlx’s; whole numbers from 0 to 262143, refused outside, and above MAX_CONNECTIONS the boot refuses it, where sqlx would clamp it in silence |
CONNECT_TIMEOUT_SECS |
connection-acquire timeout in seconds, and the boot’s budget to open the pool — what Postgres refuses on every attempt (credentials, the database, TLS) fails the boot at once, the rest (a server not listening yet, starting or full, a name that does not resolve yet) is retried within it, each attempt a warn on nest_rs::orm — from 1 to 3600 (unset ⇒ 10, below the authentication guard’s 18-second net and the HTTP request timeout, so a pool that runs dry answers with its own error; Repo reaches the pool from any strategy, so an app running the authentication guard keeps it under that net: the boot refuses one at or past it) — 0 fails the boot rather than time out every acquire, and past an hour the request that asked for a connection has long been abandoned |
STATEMENT_TIMEOUT_SECS |
how long one statement runs before Postgres cancels it (statement_timeout), in seconds, from 1 to 3600 (unset ⇒ 15, below the authentication guard’s 18-second net and the HTTP request timeout) — a unit of work’s BEGIN / COMMIT / ROLLBACK included; a statement it cancels answers 503 / UNAVAILABLE, and a commit that does not answer within it plus a second is in doubt; the boot refuses one at or past a net reaching the pool, as it refuses CONNECT_TIMEOUT_SECS. migrate and seed, opened by connect_from_env, run without it |
SQLX_LOGGING |
log SQL statements |
OBSERVE_SERIALIZATION_CONFLICTS |
tag commit-time serialization conflicts at warn |
redis — <PREFIX>_REDIS__*
Section titled “redis — <PREFIX>_REDIS__*”The Redis connection every Redis binding shares — the queue’s producer and
consumer, the rate-limit store and the schedule’s occurrence lock — opened by
RedisModule, on one server, Sentinel or a Cluster alike. One connection, one variable: a throttler-only app sets
the same URL a queue app does. A second Valkey
reads the same keys under its instance — <PREFIX>_REDIS__CACHE__URL for
#[instance] struct Cache. The TLS material is read at boot, so a renewed file takes effect at the
next restart.
| Key | Meaning |
|---|---|
URL |
Redis connection string, whose scheme declares the topology: redis:// / rediss:// one server, redis-sentinel:// / rediss-sentinel:// the primary the sentinels it lists name (node= each further sentinel, sentinelServiceName= required), redis-cluster:// / rediss-cluster:// a Cluster read from the seeds it lists. An s scheme encrypts every connection and verifies each certificate for the host dialled; #insecure, which skips that, and a parameter the topology does not take, fail the boot. Any other scheme is plaintext, which a deployed profile says once at warn for each instance, but for one server on this machine’s loopback. Required in every profile — no default names a Redis, so an unset one fails the boot by name; nestrs new writes compose.yml’s into .env.development and .env.test |
TLS_CA_CERT |
PEM certificates of the authorities Redis’s certificate must chain to, replacing the system’s, which are trusted otherwise — read once at boot, SSL_CERT_FILE and SSL_CERT_DIR honoured; TLS_CA_CERT_FILE reads them from a path instead. Beside a redis:// URL, fails the boot |
TLS_CERT / TLS_KEY |
PEM client certificate chain, leaf first, and its private key, presented to a Redis that requires one — its default under TLS (tls-auth-clients yes); TLS_CERT_FILE / TLS_KEY_FILE read them from a path instead. Both or neither |
CONNECT_TIMEOUT_SECS |
boot budget for reaching Redis before failing with a named error, then the most any command a caller waits on may take from end to end — a push, a rate-limit check, a command of your own — past which it fails as a timeout — and how long the socket waits, a second at the least, before it probes an idle Redis or gives up on bytes Redis never acknowledged. A queue worker’s blocking read, on a connection of its own, waits its one second plus this budget; defaults to 10; whole seconds from 1 to 3600 — an hour, past which a Redis silent that long is gone rather than slow — refused outside, and in code anything above zero up to an hour, a sub-second budget included. An app importing the queue or the rate limiter binding keeps it under their net, 18 seconds, one importing the schedule binding under the scheduler’s, 50 seconds, and one whose authentication strategy injects the connection under the guard’s, 18 seconds — each would otherwise give up on a command still answering: the boot refuses one at or past it. Each boot attempt warns on nest_rs::redis, so an unreachable backend is a bounded boot failure rather than a process that never becomes healthy and never crashes. Refused credentials and an ACL denying the connection’s PING fail at once, and so does a database the server will not select — an index it does not have, past a Cluster’s cluster-databases, an ACL user without +select — named by the index the URL ends in, and a server that is not the topology the URL declares; a Redis loading its dataset, busy running a script or failing over is retried within the budget, and one still not ready when it runs out fails naming its last answer |
redis__queue — <PREFIX>_REDIS__QUEUE__*
Section titled “redis__queue — <PREFIX>_REDIS__QUEUE__*”The Redis queue binding’s own settings, read by a bare RedisQueueModule import
or pinned through RedisQueueModule::for_root. Two segments because the config
sits in the crate’s queue/ folder: the crate’s word, then the binding’s —
exactly the stem RedisQueueConfig is named from. A queue on a named instance
reads them with the instance between the two: <PREFIX>_REDIS__CACHE__QUEUE__*.
| Key | Meaning |
|---|---|
LEASE_SECS |
how long a delivery holds its job without a renewal. The worker renews it every third of this while the attempt runs; once it lapses, the next worker that asks takes the job, so it is also how long a crashed replica’s job waits before another runs it. Defaults to 30; below 1 or above 3600 is rejected, and so is a lease of no more than one and a half times <PREFIX>_REDIS__CONNECT_TIMEOUT_SECS: a renewal sent a third into the lease may wait out the whole budget, and would land after the lease lapsed |
queue — <PREFIX>_QUEUE__*
Section titled “queue — <PREFIX>_QUEUE__*”The queue port’s worker settings, read once a #[processor] host brings
QueueModule or an app imports it, and
pinned through QueueModule::for_root. The port’s own word, so the window
survives a swap of the backend underneath.
| Key | Meaning |
|---|---|
SHUTDOWN_TIMEOUT_SECS |
the drain window after a shutdown signal: running attempts finish inside it, less a reserve, and one still running as it closes is interrupted and its job handed back to the queue before it ends. Defaults to 20, so the way down fits Kubernetes’ default grace period; below 1 or above 3600 is rejected |
storage — <PREFIX>_STORAGE__*
Section titled “storage — <PREFIX>_STORAGE__*”| Key | Meaning |
|---|---|
URL |
the store, whose scheme picks the backend: s3://<bucket>[/<prefix>], or memory:/// in a declared development or test profile alone. No default names a store, in any profile, so an unset URL fails the boot by name; another scheme fails it naming the scheme, never quoting the URL. The boot proves the bucket: one that does not exist fails it naming this variable. Beside memory:///, any S3 key below set in the deployment fails the boot naming it |
ENDPOINT |
S3 only: the server’s endpoint (unset ⇒ AWS); an https:// endpoint’s certificate is verified against the system’s authorities, or TLS_CA_CERT’s |
TLS_CA_CERT |
S3 only: PEM certificates of the authorities the endpoint’s certificate must chain to, replacing the system’s; TLS_CA_CERT_FILE reads them from a path instead. Holding no certificate, or beside an http:// endpoint, fails the boot |
TLS_CERT / TLS_KEY |
refused: object_store presents no client certificate, so either fails the boot, naming it |
REGION |
S3 only: the region requests are signed for |
ACCESS_KEY / SECRET_KEY |
S3 only: static credentials — no default holds a pair, in any profile, so an unset pair fails the boot by name. A key the store rejects — a 401, or S3’s InvalidAccessKeyId, SignatureDoesNotMatch or InvalidSecurity — fails the boot naming both, and reads down on a probe; any other 403, most often a policy without s3:ListBucket, boots on with one warn naming both |
FORCE_PATH_STYLE |
S3 only: path-style vs virtual-hosted addressing |
ALLOW_HTTP |
S3 only: reach the endpoint over plain http:// — unset is open in a declared development or test profile and closed everywhere else, so credentials never travel unencrypted by omission. Closed + an http:// ENDPOINT fails boot, naming the variable; the refusal covers presigned URLs, which are signed locally and would otherwise ship a working plaintext URL. A deployment that opens it to an http:// endpoint boots, and the store’s opening says so at warn |
OPERATION_TIMEOUT_SECS |
the most a call waits for the store’s answer, every retry included, and the boot’s proof of the bucket — an upload’s body is part of its request, and put_stream moves each 5 MiB part within it. Retries stop once half of it is spent, so a call whose attempts keep failing ends on the store’s error and its cause; past it a call fails as its own error naming this variable, followed by how its last attempt failed when that attempt ended on an error or a failing status. Defaults to 15; whole seconds from 1 to 3600, refused outside. An app whose authentication strategy injects Storage keeps it under the guard’s 18 seconds: the boot refuses one at or past it |
READ_TIMEOUT_SECS |
the most a download waits for its next bytes while it is read: one that stalls longer is cut and resumed from where it stopped, provided the object is still the version it started on, and fails naming this variable when the resumed body sends nothing within it; one that moves, or whose reader pauses, is never cut. Defaults to 30; whole seconds from 1 to 3600, refused outside |
static_files — <PREFIX>_STATIC_FILES__*
Section titled “static_files — <PREFIX>_STATIC_FILES__*”Read once StaticFilesModule is imported, and pinned through its for_root
(Static files).
| Key | Meaning |
|---|---|
ROOT |
the directory StaticFilesModule serves, relative to the working directory. Resolved at boot: unset, missing or not a directory fails boot, and so does any value beside a folder embedded in the binary (Embedded::of::<T>()) |
PATH |
where the files answer, outside the global prefix and after every route — default /. A literal path the router matches as written: an empty, . or .. segment, template syntax ({ }), what the router reads as a parameter (: * <), %, ?, # or \ is refused |
SPA_FALLBACK |
answer a browser’s navigation that no file matches with the root’s index.html — default false. A request that does not ask for a page, or whose last segment names a file, still gets the 404 problem document |
MAX_AGE_SECS |
Cache-Control: public, max-age on every file but an HTML document, from 1 to a year (31536000); 0 or unset revalidates every file (no-cache), the default |
authn — <PREFIX>_AUTHN__*
Section titled “authn — <PREFIX>_AUTHN__*”JWT key material and validation for nest-rs-authn. A resource server sets only
the verification side (SECRET, PUBLIC_KEY or JWKS_URI); the issuer app
also sets the signing side. The key material is read at boot, so a rotated file
takes effect at the next restart; a JWK Set is fetched when a token first needs
it and kept fresh (JWT).
| Key | Meaning |
|---|---|
SECRET |
HS256 shared secret (≥ 32 bytes) — signs and verifies. Beside either key it fails the boot |
PRIVATE_KEY |
EdDSA private key (PEM) — issuer only, to sign; PRIVATE_KEY_FILE reads it from a path instead. Without PUBLIC_KEY, or beside the public key of another pair, fails the boot |
PUBLIC_KEY |
EdDSA public key (PEM) — to verify; PUBLIC_KEY_FILE reads it from a path instead |
JWKS_URI |
the JWK Set an external issuer publishes its keys at — verify-only. https only; beside SECRET, PRIVATE_KEY or PUBLIC_KEY, fails the boot |
ALGORITHMS |
comma-separated JOSE algorithms a token may be signed with, case-sensitive (EdDSA,RS256). Unset: HS256 with SECRET, EdDSA with a PEM key, every asymmetric one (RS256–RS512, PS256–PS512, ES256, ES384, EdDSA) with JWKS_URI. A secret or a PEM key takes exactly one that fits it, a JWK Set never an HS* one; an unknown name, none included, fails the boot |
TLS_CA_CERT |
PEM certificates of the authorities the JWKS_URI endpoint’s certificate must chain to, replacing the system’s; TLS_CA_CERT_FILE reads them from a path instead. Holding no certificate, or set without JWKS_URI, fails the boot |
TLS_CERT / TLS_KEY |
PEM client certificate chain, leaf first, and its private key, presented to a JWKS_URI endpoint that requires one; TLS_CERT_FILE / TLS_KEY_FILE read them from a path instead. Both or neither; without JWKS_URI, they fail the boot |
ISSUER |
the iss every token this app mints carries and every token it verifies must name. Required (RFC 9068 §2.2, §4): unset or blank, the boot fails naming it — but under OAuthResourceModule, where a token’s iss must be one of its AUTHORIZATION_SERVERS and a set ISSUER must be one of them, or the boot fails naming both; unset there, the app mints no access token |
AUDIENCE |
the aud this app requires, and the one a token it mints for itself carries — a token it mints for another resource names that resource. Required (RFC 9068 §2.2, §4): unset or blank, the boot fails naming it, and a token naming another audience or none is refused. Under OAuthResourceModule, unset is its RESOURCE |
ALLOW_ANY_AUDIENCE |
opt out of the audience check and accept a token minted for another service (default false), in place of AUDIENCE: the app then mints only for a resource it names (sign_for). Refused beside AUDIENCE and beside OAuthResourceModule, and reported at warn once per boot |
LEEWAY_SECS |
clock-skew leeway in seconds, 0 to 300 (default 30) — RFC 7519 §4.1.4’s “no more than a few minutes”; past it an expired token still verifies |
EXPIRES_IN_SECS |
minted-token lifetime in seconds, 1 to 2592000 — thirty days (default 3600) |
EXPLICIT_TYPING |
require the JWT typ header to name the token’s type (default true); false for an issuer stamping a plain typ: JWT, or none |
oauth__client — <PREFIX>_OAUTH__CLIENT__*
Section titled “oauth__client — <PREFIX>_OAUTH__CLIENT__*”The login flow’s provider endpoints, read by OAuthClientConfig in
nest-rs-oauth-client. Every URL and credential is required, so an unconfigured app fails
boot naming the field:
| Key | Meaning |
|---|---|
CLIENT_ID / CLIENT_SECRET |
the registered OAuth2 client credentials |
AUTH_URL |
provider authorization endpoint (where the user consents); https only (RFC 6749 §3.1) |
TOKEN_URL |
provider token endpoint (code → tokens); https only (RFC 6749 §3.2) |
REDIRECT_URL |
this app’s callback the provider returns to; https, or http on localhost, 127.0.0.1 or [::1] (RFC 8252 §7.3) in a declared development or test profile (<PREFIX>_ENV) alone |
USERINFO_URL |
provider endpoint the profile is fetched from; https only (RFC 6750 §5.3) |
SCOPES |
comma-separated scopes requested at authorization (empty by default), each an RFC 6749 §3.3 scope-token: one holding a space or a " fails the boot |
AUTHORIZATION_PARAMETERS |
a JSON object of strings the authorization request carries beside the client’s own, under the provider’s names ({"access_type":"offline","prompt":"consent"}); none by default. A name outside RFC 6749 §8.2’s grammar (letters, digits, -, ., _), a parameter the client sends itself — response_type, client_id, redirect_uri, scope, state, code_challenge, code_challenge_method, nonce, response_mode, request, request_uri — or sends the token endpoint alone — client_secret, client_assertion, client_assertion_type, code_verifier — in any case, and one with no value or named twice fails the boot |
TLS_CA_CERT |
PEM certificates of the authorities the provider’s certificate must chain to, replacing the system’s; TLS_CA_CERT_FILE reads them from a path instead. Holding no certificate fails the boot |
TLS_CERT / TLS_KEY |
PEM client certificate chain, leaf first, and its private key, presented to a provider that requires one; TLS_CERT_FILE / TLS_KEY_FILE read them from a path instead. Both or neither |
oauth__server — <PREFIX>_OAUTH__SERVER__*
Section titled “oauth__server — <PREFIX>_OAUTH__SERVER__*”The clients an authorization server registers (RFC 6749 §2), read by
OAuthServerConfig<P> in nest-rs-oauth-server once
OAuthServerModule::<P> is imported (or OAuthServerModule::for_root(cfg)
pins it), P the payload the app’s own type carries:
| Key | Meaning |
|---|---|
CLIENTS |
a JSON array of clients, each client_id, client_secret, scopes (the most it may be granted), resources (RFC 8707: what its tokens may be minted for) and the app’s payload; CLIENTS_FILE reads it from a path instead. At least one required; a duplicate or empty id, an empty secret or a client registered for no resource fails the boot naming the client, never its secret |
oauth__resource — <PREFIX>_OAUTH__RESOURCE__*
Section titled “oauth__resource — <PREFIX>_OAUTH__RESOURCE__*”OAuthResourceModule is what turns the app into a conformant OAuth 2.1
resource server (RFC 9728) and what an MCP server needs. Importing it binds the
token verifier to the resource: a token is accepted only when its aud is
RESOURCE — or <PREFIX>_AUTHN__AUDIENCE when set, warned when it differs —
and its iss is one of AUTHORIZATION_SERVERS (RFC 9068 §4), or
<PREFIX>_AUTHN__ISSUER when set, which must be one of them. A token carrying
no aud or no iss is refused. The MCP endpoint’s Host allowlist admits
RESOURCE’s host.
| Key | Meaning |
|---|---|
RESOURCE |
this deployment’s canonical resource URI — the value tokens must carry as aud: https, a host, no userinfo, no fragment, plain http on loopback in a development or test profile alone. Required under the module |
AUTHORIZATION_SERVERS |
comma-separated issuer identifiers allowed to mint tokens for it, each held to RESOURCE’s rules — a token’s iss must equal one exactly. At least one required |
SCOPES_SUPPORTED |
comma-separated scope set advertised in the metadata document and the WWW-Authenticate challenge — unset, the Scopes OAuthResourceModule::for_root declares |
BEARER_METHODS_SUPPORTED |
how a token may be presented — defaults to header, the only form accepted |
RESOURCE_NAME |
human-readable name for a consent screen |
RESOURCE_DOCUMENTATION |
URL of developer documentation for this resource; userinfo fails the boot |
RESOURCE_POLICY_URI |
URL of this resource’s privacy policy, advertised in the metadata document; userinfo fails the boot |
RESOURCE_TOS_URI |
URL of this resource’s terms of service, advertised in the metadata document; userinfo fails the boot |
mcp — <PREFIX>_MCP__*
Section titled “mcp — <PREFIX>_MCP__*”| Key | Meaning |
|---|---|
ALLOWED_HOSTS |
comma-separated Host authorities accepted (anti-DNS-rebinding). Defaults to loopback, so a public deployment must name itself — unless it imports OAuthResourceModule, whose RESOURCE host is admitted beside the list; an empty list disables the check and is reported at warn |
LEGACY_SESSION_MODE |
keep sessions alive for protocol revisions older than 2026-07-28 — default true |
JSON_RESPONSE |
answer simple operations with application/json instead of an SSE stream — default false |
SSE_KEEP_ALIVE_SECS |
SSE keep-alive ping interval, from 1 to 3600 (0 ⇒ none) — default 15 |
SSE_RETRY_SECS |
retry: interval advertised on SSE priming events, a session’s streams included, from 1 to 3600 (0 ⇒ none) — default 3 |
MAX_REQUEST_BODY_BYTES |
cap on a single POST body, enforced while streaming — default 4 MiB; whole numbers from 1 to 1073741824 (a gibibyte), refused outside |
STATELESS_PROTOCOL_METADATA_REQUIRED |
require per-request protocol metadata on stateless POSTs (SEP-2243) — default false |
OPERATION_TIMEOUT_SECS |
how long one operation may run, subscriptions/listen aside — default 20, the request timeout’s; whole seconds from 1 to 3600, or 0 ⇒ none. An overrun answers a JSON-RPC internal error whose data.reason is timeout. A timeout past <PREFIX>_HTTP__SHUTDOWN_TIMEOUT_SECS, or 0, files one warn at boot |
MAX_CONCURRENT_SESSIONS |
live sessions one endpoint holds, whole numbers from 1 to 1048576 — default 1024. Past it an initialize is answered 503 with Retry-After: 5; a stateless request is never refused for it |
SESSION_IDLE_TIMEOUT_SECS |
how long a session may go unused before it is closed — no message from its client but a ping’s answer, none of the server’s carried to it on a stream, and no call waiting on its answer — whole seconds from 1 to 3600, never off — default 300 |
PING_INTERVAL_SECS |
how long a session’s client holding its stream may send nothing before it is sent MCP’s ping on that stream, whole seconds from 1 to 3600 (0 ⇒ none) — default 20 |
PING_TIMEOUT_SECS |
how long that ping waits for anything back before the session is closed, whole seconds from 1 to 3600, never off — default 20 |
social — <PREFIX>_SOCIAL__<PROVIDER>__*
Section titled “social — <PREFIX>_SOCIAL__<PROVIDER>__*”One sub-namespace per provider (GITHUB, GOOGLE), read only when the app
imports the provider’s module (GithubSocialModule, GoogleSocialModule).
Credentials then decide the provider’s fate: complete ⇒ active, absent ⇒ inert
with a boot warn, partial ⇒ the boot fails naming the provider.
| Key | Meaning |
|---|---|
CLIENT_ID / CLIENT_SECRET |
the provider’s OAuth app credentials |
REDIRECT_URL |
the registered callback this app is returned to |
SCOPES |
comma-separated scopes; each provider has a sensible default when unset. Each is an RFC 6749 §3.3 scope-token: one holding a space or a " fails the boot |
AUTHORIZATION_PARAMETERS |
a JSON object of strings the provider’s authorization request carries beside the client’s own ({"access_type":"offline","prompt":"consent"} for a refresh token from Google); none by default, refused as the OAuth client’s AUTHORIZATION_PARAMETERS is |
The endpoint URLs are provider constants, not config — see Social login.
Other namespaces
Section titled “Other namespaces”These read their own <PREFIX>_<NAMESPACE>__* keys. The rule is uniform: the
struct’s field name uppercased is the key. Two namespaces are not spelled the
way their section is, so the page is named rather than left to a search:
| Namespace | Documented on |
|---|---|
graphql |
GraphQL configuration |
openapi |
OpenAPI |
queue__outbox |
Delivery |
server_timing |
Server-Timing |
health |
Health |
throttler |
Rate limiting |
ws |
WebSockets |
sign_in |
the demo feature library — the Publish workspace |
The .env cascade
Section titled “The .env cascade”Values resolve highest-first: real env > pinned in module.rs (for its whole
namespace) > the app’s own apps/<app>/.env*, under development and test
alone > .env.<<PREFIX>_ENV>.local > .env.local > .env.<<PREFIX>_ENV> >
.env, and a process that leaves <PREFIX>_ENV unset runs as production. See
the env cascade for the files and
the dual-path rule for where a pinned
value sits.
Going further
Section titled “Going further”- Configuration — the typed
#[config]derive and dual-path rule. - The env cascade — layering and precedence.
- Variables nothing reads — what the boot says of a variable under the prefix that no config reads.