Production
This page is the short version: the commands and the environment variables. The full checklist, with the balancer, rolling restarts, key rotation, logout and logs, is in docs/production.md. Read it before your first deploy.
Nothing here claims that Luxel is production ready. It lists what luxel-host needs and what it refuses.
Build and verify
In your deploy pipeline:
npm run build # luxel build && luxel check npx luxel-host luxel.config.json --check # validates config, manifests, assets and runtime, then exits LUXEL_SIGNING_KEY=… npm run sign # luxel sign: the signed provenance of this build
Production serves only a signed build (Sprint 11). Make a key pair once with npx luxel keygen. Keep LUXEL_SIGNING_KEY in your pipeline's secret store and never on the hosts. Give every host the public key in LUXEL_PROVENANCE_KEYS. luxel sign writes .luxel/provenance.json and its signature next to the build. It records every file and every byte the host will serve, including the static pages, plus your dependencies from package-lock.json and, since Sprint 12, every file of the production dependencies installed next to the app (luxel-host's own included), so sign after npm ci on the image you deploy. It prints the build digest, the name of this build in logs and revocations. npx luxel verify runs the host's check without serving.
Build outputs (manifests, slot maps, templates) come from the build. Never edit them by hand, and never commit them (the template's .gitignore excludes them).
Run
LUXEL_ENV=production LUXEL_VIEW_KEYS=k1:$(head -c 32 /dev/urandom | base64) LUXEL_PROVENANCE_KEYS=k1:‹public key> npm start
npm start runs luxel-host luxel.config.json. Put TLS in front: the session cookie is __Host-…; Secure. HTTP/2 is recommended. luxel-host answers only the host names in LUXEL_HOSTS (required in production): any other Host gets 421 before anything runs, which stops DNS rebinding and cache poisoning through Host. /healthz answers whatever the Host, so a balancer can probe a node by its IP. A proxy in front should still answer only your names.
In a real deploy the key comes from your secret store, not from the command line, and it is the same on every node.
Environment variables
| Variable | Meaning |
|---|---|
| LUXEL_ENV | production, development or test. With production the host refuses to start with an unsafe setup |
| LUXEL_VIEW_KEYS | kid:base64secret[,kid:base64secret…], 32 random bytes or more each. Required to serve; never generated by luxel-host |
| LUXEL_HOSTS | The host names this app answers to, separated by commas (no scheme, port or wildcard), e.g. app.example.com,www.example.com. Required in production; elsewhere checked only when set (Sprint 12) |
| LUXEL_PROVENANCE_KEYS | kid:‹base64url public key>[,…] (from luxel keygen). Required in production: the build must be signed by one of them |
| LUXEL_REVOCATION_POLL_MS | How often a node reads the revocation list (default 5000) |
| LUXEL_REVOKED_BUILDS | One node without a shared list: build digests that must not start |
| LUXEL_OPEN_DELIVERY_MS | Under identity.mode: "gateway-jwt": how long a session opened for a request lives without the confirmation that its cookie was delivered (default 30000; 100 to 300000). See Behind a gateway |
| LUXEL_OPEN_CLOCK_MARGIN_MS | How far the clocks of the hosts and of a delegated session backend may differ (default 5000; 0 to 60000). Under identity.mode: "gateway-jwt" it bounds the deadlines of a session open; in every mode it is what the start-up clock check compares against (Clock margin) |
| LUXEL_OPEN_CONFIRM_MS | Under identity.mode: "gateway-jwt": how long the response that delivers a new session waits for the store's confirmation of that session; after it the request is refused (503, no cookie) and the session is closed (default 5000; 50 to 60000) |
| PORT | Listening port (default 8080) |
| LUXEL_NODES | How many nodes run. Above 1, production requires shared stores (Sessions) |
| LUXEL_TRUST_PROXY | The proxies in front of the host, as addresses or CIDRs separated by commas (10.0.4.17, 10.0.4.0/24,2001:db8::/48). For a request from a listed peer the client address is the first X-Forwarded-For entry, from the right, that is not listed; any other peer is its socket address. Unset or 0: nothing is trusted. There is no trust-all value: 1, a CIDR wider than /8 (IPv4) or /16 (IPv6), entries that together cover more than a /6 (IPv4) or /14 (IPv6), an IPv4-mapped IPv6 entry or a malformed list refuses to start. See Behind a gateway |
| LUXEL_VIEW_TOKEN_TTL_MS | View token lifetime (default 15 minutes) |
| LUXEL_SHUTDOWN_DELAY_MS | On SIGTERM, how long /healthz answers 503 before the listener closes (default: no delay; a positive whole number of milliseconds when set); longer than your balancer needs to see the node as down |
| LUXEL_SHUTDOWN_GRACE_MS | How long requests in flight may finish (default 10 s) |
| LUXEL_GATEWAY_LOG | 0 silences the per-request log lines |
| LUXEL_ACCESS_LOG | 1 prints one line per request (which node served what); 0 or unset: none. Meant for cluster tests |
| LUXEL_CSS | inline, link or auto: overrides css.mode of luxel.config, the mode of the per-view CSS of filled pages (measurements; see Views). |
| LUXEL_BOOT_PRELOAD | 0 or 1: overrides preload of luxel.config, for pages the runtime renders (filled pages never preload at high priority). |
| DATABASE_URL | Not read by luxel-host itself; your bindings read it (for example for @luxel-framework/postgres) |
Do not set LUXEL_STREAM in production: it is a measurement override, and the host refuses to start with it. Early send is configured per view with views.‹id>.stream (off by default).
What the host refuses in production
With LUXEL_ENV=production, luxel-host exits with luxel-host: not starting: ‹reason> (the reason never contains a value) when:
- LUXEL_VIEW_KEYS is missing, or a key is malformed or shorter than 32 bytes;
- LUXEL_PROVENANCE_KEYS is missing, the build is not signed by one of them, or any build file or served byte differs from the signed provenance (changed, missing or added; a static page that fills differently; the bindings or one of the app's own server modules, Sprint 11 RT-8; a file of an installed production dependency, Sprint 12); or the build is revoked;
- LUXEL_HOSTS is missing (Sprint 12);
- LUXEL_NODES is above 1 and the session store or rate limiter is not shared, or, with a static view, the replay guard or sign-in rate limiter is not shared, or the revocation list is not shared;
- the configuration is invalid (unknown field, bad JSON, a bad value of an LUXEL_* setting);
- LUXEL_STREAM or LUXEL_SERVER_TIMING is set (both are measurement switches).
In every environment, with identity.mode: "gateway-jwt", it also refuses the combinations stage S1-A does not support, each with a stable code: streamed pages (LUXEL-M001, stage S1-B) and a delegated or third-party session store (LUXEL-M002, stage S1-C). See the support matrix.
When something is compromised
Rotate view keys, end sessions, revoke a build (npx luxel revoke ‹digest>: every node of that build stops serving within seconds) or rotate the signing key: docs/security/incident-response.md.
Health and shutdown
- GET /healthz answers a word and a status, no data; 503 while draining (draining), and, with a session store that offers a reference clock, 503 until the clock check proved the skew within the clock margin (clock-skew beyond it, clock-unmeasured not yet decided; below).
- On SIGTERM or SIGINT the node turns /healthz to 503 and answers with Connection: close for LUXEL_SHUTDOWN_DELAY_MS, then stops accepting connections and lets requests in flight finish.
- Restart one node at a time.
Clock margin
The hosts of a deployment and, with a delegated session store, its backend must keep their clocks within the clock margin (LUXEL_OPEN_CLOCK_MARGIN_MS, 5 s by default): under identity.mode: "gateway-jwt" the deadline of a session open is chosen by the host that opens it and judged by whoever reads it (the PostgreSQL store with the reading host's clock, a delegated backend with its own). Run NTP (or your platform's time sync) on every host and on the backend.
At start, when the session store offers a reference clock (SessionStore.now(): the PostgreSQL store reads the database's clock; a delegated store, its backend's when the delegate has now), the host compares its own clock with it. The reference was read at some moment of the call, so each call places the skew (the reference minus the host) in an interval as wide as its round trip, measured on the monotonic clock; if the host's wall clock steps during a call, the interval widens to cover both readings. Nothing is rounded before it is compared. Up to three calls are made in a round, each judged on its own (never combined: the host's clock may step between two calls). The start waits up to 3 s for the first round; the host then serves either way.
| Result | Log line | /healthz |
|---|---|---|
| The whole interval is within the margin | none (luxel.clock.measured, info, after an unmeasured round) | 200 ok; the check is done |
| The whole interval is beyond the margin | luxel.clock.skew (warn), code LUXEL-C001, with skewMs (the middle of the interval), skewLowMs, skewHighMs, marginMs, roundTripMs | 503 clock-skew for as long as the host runs, so a balancer keeps it out. Synchronize the clocks and restart it |
| Not decided: the reference clock fails, does not answer within 3 s, answers no time, or the interval straddles the margin (a round trip too long for it, a clock step) | luxel.clock.unmeasured (warn), code LUXEL-C002, with attempt and retryMs | 503 clock-unmeasured: an unmeasured skew is not taken for one within the margin. Retried after 1, 2, 5, 10 and then every 30 s until it decides; a call that answers after its 3 s is still judged, and no new call is made while it hangs |
The memory store has no reference clock (it is the host's own) and is not checked. Once decided, the check is not repeated: a clock that drifts later is not seen. The round trip to the reference must be well under the margin for the check to decide; with LUXEL_OPEN_CLOCK_MARGIN_MS=0 it can decide only a skew of exactly zero. With PostgreSQL, the database's clock is a common reference, not the clock that judges: two hosts each within the margin of it may differ from each other by up to twice the margin. The PostgreSQL store's sweep of sessions never read after their confirmation (purgeExpired, unusedMs) allows for that: a session opened under gateway-jwt keeps its unused mark twice the opening host's margin longer, so a host up to twice the margin ahead never sweeps a session another host is still delivering. Give every host the same margin, and run the scheduled purgeExpired() on a host whose clock is within it.