On this page

Self-hostConfiguration

Configuration

Each qbrix service reads its settings from environment variables with its own prefix: PROXY_ for the API, MOTOR_ for selection, CORTEX_ for learning and TRACE_ for the analytics writer. A few logging variables are shared.

You rarely set these directly:

  • Docker Compose reads .env, whose shorter names (SIGNUP_MODE, SMTP_HOST, …) are mapped onto the variables below. .env.example documents each one.
  • Helm sets them from the chart's values, such as proxy.config.signupMode. The chart's README lists the values.

This page is the reference underneath both, for when you run the images some other way or need a setting neither exposes.

API (PROXY_)

The proxy serves the REST API and the console's backend, and routes selection to the selection service.

Secrets

Set all three to long random values. bin/selfhost-init and the Helm chart generate them for you.

VariableDefaultDescription
PROXY_POSTGRES_PASSWORDqbrixPostgres password
PROXY_JWT_SECRET_KEYchange-me-in-productionSigns console sessions. Changing it signs everyone out
PROXY_TOKEN_SECRETchange-me-in-productionSigns the request_id that select returns and feedback sends back. Changing it invalidates selections still waiting for feedback

Databases and services

VariableDefaultDescription
PROXY_POSTGRES_HOST / _PORTlocalhost / 5432Postgres
PROXY_POSTGRES_USER / _DATABASEqbrix / qbrixPostgres user and database
PROXY_REDIS_HOST / _PORTlocalhost / 6379Redis
PROXY_REDIS_PASSWORD / _DBunset / 0Redis auth and database number
PROXY_MOTOR_HOST / _PORTlocalhost / 50051The selection service
PROXY_CORTEX_HOST / _PORTlocalhost / 50052The learning service

Signup and accounts

VariableDefaultDescription
PROXY_SIGNUP_MODEfirst-userfirst-user, invite-only or open. See who can sign up
PROXY_JWT_ACCESS_TOKEN_EXPIRE_MINUTES30Console session lifetime before a silent refresh
PROXY_JWT_REFRESH_TOKEN_EXPIRE_DAYS7How long a console sign-in lasts
PROXY_TOKEN_MAX_AGE_MSunsetHow old a selection may be and still accept feedback, in milliseconds. Unset means no limit

Email

VariableDefaultDescription
PROXY_EMAIL_PROVIDERautoauto, smtp, resend or none. See Email
PROXY_EMAIL_FROMqbrix <noreply@localhost>Sender address
PROXY_SMTP_HOST / _PORTunset / 587SMTP relay
PROXY_SMTP_USERNAME / _PASSWORDunsetSMTP credentials
PROXY_SMTP_STARTTLStrueUpgrade the SMTP connection with STARTTLS
PROXY_RESEND_API_KEYunsetResend API key
PROXY_EMAIL_VERIFICATION_TTL_SECONDS86400How long a verification link stays valid

Network

VariableDefaultDescription
PROXY_HTTP_PORT8080REST API port
PROXY_GRPC_PORT50050gRPC API port
PROXY_CONSOLE_URLunsetPublic console URL used in email links. Unset falls back to http://localhost:3001; Compose and Helm set it for you
PROXY_CORS_ORIGINSunsetExtra browser origins allowed to call the API with credentials, comma separated. Only needed when the console is served from a different origin than the API
PROXY_TRUSTED_PROXY_HOPS1Reverse proxies in front of the API that append to X-Forwarded-For. The login rate limit keys on the client address this many hops from the right
PROXY_TRUST_CLOUDFRONT_HEADERfalseKey the login rate limit on CloudFront-Viewer-Address. Only safe when CloudFront is the sole way in and its origin request policy adds that header

Analytics

VariableDefaultDescription
PROXY_ANALYTICS_ENABLEDfalseServe insights and the event log, and publish the events they are built from. Needs ClickHouse and the analytics writer
PROXY_CLICKHOUSE_HOST / _PORTlocalhost / 8123ClickHouse HTTP interface
PROXY_CLICKHOUSE_USER / _PASSWORD / _DATABASEdefault / unset / qbrixClickHouse credentials and database

Environment

VariableDefaultDescription
PROXY_RUNENVprodLeave it at prod. dev turns off authentication and signs every request in as a built-in development user, for working on qbrix itself
Careful

Never set PROXY_RUNENV=dev on an install anyone else can reach. Every request is then accepted without a key or a session.

PROXY_EE_ENABLED and the PROXY_STRIPE_* variables belong to the managed cloud edition. Leave them unset on a self-hosted install.

Selection (MOTOR_)

VariableDefaultDescription
MOTOR_REDIS_HOST / _PORTlocalhost / 6379Redis
MOTOR_REDIS_PASSWORD / _DBunset / 0Redis auth and database number
MOTOR_GRPC_PORT50051gRPC port the API calls
MOTOR_PARAM_CACHE_TTL60Seconds learned parameters are cached before re-reading Redis. Traffic allocation moves when this refreshes, not on every feedback

Learning (CORTEX_)

Run exactly one learning service. It applies feedback in order, and two instances would race to update the same parameters.

VariableDefaultDescription
CORTEX_REDIS_HOST / _PORTlocalhost / 6379Redis
CORTEX_REDIS_PASSWORD / _DBunset / 0Redis auth and database number
CORTEX_GRPC_PORT50052gRPC port
CORTEX_BATCH_SIZE256Feedback events trained on per batch
CORTEX_NUM_WORKERS4Training workers

Analytics writer (TRACE_)

Only runs with analytics on. It scales horizontally; give each replica its own TRACE_CONSUMER_NAME.

VariableDefaultDescription
TRACE_REDIS_HOST / _PORTlocalhost / 6379Redis
TRACE_REDIS_PASSWORD / _DBunset / 0Redis auth and database number
TRACE_CLICKHOUSE_HOST / _PORTlocalhost / 8123ClickHouse HTTP interface
TRACE_CLICKHOUSE_USER / _PASSWORD / _DATABASEdefault / unset / qbrixClickHouse credentials and database
TRACE_CONSUMER_NAMEworker-0This replica's identity in the event stream. Must differ per replica
TRACE_BATCH_SIZE500Events written to ClickHouse per batch
TRACE_FLUSH_INTERVAL_SEC5.0Longest an event waits before it is written

Every service

VariableDefaultDescription
{SERVICE}_SHUTDOWN_GRACE_SEC20Seconds a service spends draining in-flight work on shutdown. On Kubernetes, terminationGracePeriodSeconds must be longer
LOG_LEVELINFODEBUG, INFO, WARNING, ERROR or CRITICAL. {SERVICE}_LOG_LEVEL overrides it for one service, e.g. MOTOR_LOG_LEVEL
LOG_FORMATtextjson for structured logs, text for people
SENTRY_DSNunsetSend errors to Sentry. {SERVICE}_SENTRY_DSN overrides it for one service. Unset sends nothing

Next steps