Nyx

Application

Configuration

Every switch is an environment variable read by nyx.config.load(). There is no second config file format.

VariableMeaning
NYX_ENVdevelopment, test, or production
NYX_SECRET_KEYrequired in production, at least 32 characters
NYX_PORTlisten port
NYX_DB_PATHSQLite file for the app ORM
DATABASE_URLsqlite:///..., or postgres:// / mysql:// for those drivers
NYX_AUTO_MIGRATE1 or 0. Production default is 0. Prefer nyx db migrate
NYX_WORKERS1 uses serve. Greater than 1 uses serve_multicore
NYX_SESSION0 skips session middleware. CSRF forces the session back on
NYX_CSRFCSRF middleware
NYX_CSRF_API_EXEMPTopts /api/ out of CSRF
NYX_CSPContent-Security-Policy value
NYX_SECURITY_HEADERS0 skips the security after-middleware
NYX_LOCALEdefault locale for nyx.i18n
NYX_RATE_LIMIT_STOREmemory or db. Auto-db when workers are greater than 1 and this is unset
NYX_TRUST_X_FORWARDED_FOR1 trusts the edge’s forwarded client
NYX_TRUSTED_PROXIESIP allowlist. Forwarded headers count only when the peer is on the list
NYX_TLS_CERT, NYX_TLS_KEYPEM paths. Nyx then uses serve_tls or serve_multicore_tls
NYX_REQUEST_ID0 skips the uuid and X-Request-Id
NYX_REQUEST_HEADERS0 takes the header-skip path (handle_bare)
NYX_IPV6, NYX_IPV6_ONLYIPv6 listen. See Boot and dispatch
NYX_MAIL_SMTP_PORTdefault 465, immediate TLS
NYX_MAIL_SMTP_STARTTLS1 opens plain TCP then STARTTLS, typical of port 587

Secrets#

NYX_SECRET_KEY signs the session and CSRF tokens. Generate it outside the repo and inject it in the process environment. Do not commit it. The noxlang.com stack reads the same variable for its own Nyx process; a framework app in production should have its own value.

Databases#

A sqlite:/// URL and NYX_DB_PATH both select the default model. postgres:// and mysql:// boot through nyx.pg_model / nyx.mysql_model and the matching session and auth engines. SQL dialects stay split: ? versus $n, RETURNING, and identifier quotes. last_insert_rowid is not part of the shared protocol.

Behind the tunnel#

noxlang.com’s own container sets NYX_TRUST_X_FORWARDED_FOR because Cloudflare is the only client that can reach it. Copy that only when you know the peer is the proxy. An empty NYX_TRUSTED_PROXIES plus the trust flag is the older “the operator asserts the edge” behaviour. A non-empty allowlist uses X-Forwarded-For only when the connecting IP is on the list.

HttpRequest.peer_addr ("ip:port") is the rate-limit key when trust is off. An empty peer, which tests and dispatch_from_parts can produce, shares the "direct" bucket. Rate-limit keys parse [addr]:port as the address inside the brackets.