Skip to content

Configuration ​

Every setting is an environment variable. Most of them can also be stored in the database and changed at runtime.

Where settings come from ​

Precedence, from lowest to highest:

  1. the default
  2. the value stored in the database (<AUTH_PREFIX>configuration, persistent settings only)
  3. the programmatic value: server.config of the Nuxt module, config of createMongocampServer
  4. the environment variable

Persistent settings can be changed at runtime with PATCH /system/configurations/{key}. The value is checked against the type of the setting. A setting that is set by the environment cannot be changed that way (400). Environment values are not written into the database. DELETE /system/configurations/{key} (2.6) sets the default again, at once for a setting that needs no restart; not for AUTH_SECRET (its default is generated).

GET /system/configurations lists all settings with their effective value, type and whether a change needs a restart. CONNECTION_PASSWORD and AUTH_SECRET are answered as ********.

Since 2.8 every entry also says where its value comes from and whether it is the current default:

FieldMeaning
sourceenv (environment variable), option (programmatic value), patched (set with PATCH), stored (stored, but nobody set it — the default a first start wrote, possibly the default of an older server), default (nothing stored, or not persistent)
defaultValueThe current default in the form of value. Left out for AUTH_SECRET (generated); masked like value for secrets
isDefaultvalue equals the current default (lists in the same order, numbers by value)

After an upgrade ​

The server stores every persistent default at the first start of a database, and a stored value wins over a newer default. A few known old defaults are replaced at the start (AUTH_GRANT_DENIED_STATUS, CORS_HEADERS_EXPOSED, AGGREGATION_STAGES_DENIED, DOCS_SWAGGER). For everything else:

  • the start logs one warning with the keys whose stored value nobody set and that differ from the current default (keys only, no values);
  • GET /system/configurations shows the same entries as source: "stored" with isDefault: false;
  • DELETE /system/configurations/{key} takes the current default, PATCH keeps the value (it is then patched and no longer reported).

An environment variable or a programmatic value hides the stored value, so it is not reported. 3.0 is planned to stop storing defaults at all.

Value formats ​

TypeEnvironment formatExample
StringtextCONNECTION_DATABASE=shop
Longwhole numberSERVER_PORT=9000
Booleantrue / falseDOCS_SWAGGER=true
Durationnumber with unit (ms, s, m, h, d, or words like hours)AUTH_EXPIRING_DURATION=12h
ListJSON array, or comma separatedCORS_ORIGINS_ALLOWED='["https://app.example.com"]'

$ in lists

Quote values with $ for the shell: AGGREGATION_STAGES_DENIED='["$function","$out"]'.

Connection ​

Not persistent: these are needed before the database is reachable. A restart is required to change them.

SettingDefaultDescription
CONNECTION_HOSTlocalhostMongoDB host
CONNECTION_PORT27017MongoDB port
CONNECTION_DATABASEmongocampDefault database: collections without a db: prefix live here, and so do the mc_* collections
CONNECTION_USERNAME—Database user
CONNECTION_PASSWORD—Password of the database user
CONNECTION_AUTHDBadminAuthentication database

A full connection string (connectionUri, or NUXT_MONGOCAMP_SERVER_CONNECTION_URI for the Nuxt module) replaces host, port and credentials.

Auth ​

SettingDefaultPersistentDescription
AUTH_PREFIXmc_noPrefix of the server's collections (mc_users, mc_roles, mc_token_cache, mc_configuration, mc_jobs, ...)
AUTH_HANDLERmongoyes, restartmongo: users and roles in the database. static: from AUTH_USERS / AUTH_ROLES
AUTH_USERS["{}"] (none)noUsers of the static handler, see Authentication
AUTH_ROLES["{}"] (none)noRoles of the static handler
AUTH_SECRETrandom, storedyesSecret that signs the tokens. Generated at the first start and stored, so all instances and restarts share it
AUTH_EXPIRING_DURATION6hyesLifetime of a token
AUTH_REFRESH_GRACE_DURATION60syesHow long a token stays valid after /auth/token/refresh replaced it
AUTH_CACHE_DBtrueyesKeeps tokens (as SHA-256) in mc_token_cache so they survive restarts and are shared between instances
AUTH_APIKEYLENGTH32yesLength of generated API keys
AUTH_GRANT_DENIED_STATUS403yesStatus for a logged-in user without the grant: 403, or 401 (clients clear the session on it). Since 2.6 a 401 that a database before 2.2 stored as default becomes 403 at the start; a patched 401 stays
AUTH_BEARERtrueyes, restartAccept bearer tokens
AUTH_BASICtrueyes, restartAccept Basic auth
AUTH_TOKENtrueyes, restartAccept API keys (X-AUTH-APIKEY)

Server and CORS ​

SettingDefaultDescription
SERVER_INTERFACE0.0.0.0Listener of the standalone server (restart)
SERVER_PORT8080Port of the standalone server (restart)
CORS_ORIGINS_ALLOWED["http://localhost:8080"]Allowed origins. An allowed origin is answered with credentials and Vary: Origin; another origin gets no Access-Control-Allow-Origin (2.5); an empty list allows any origin with * and without credentials
CORS_HEADERS_ALLOWED["Authorization", "Content-Type", "X-Requested-With", "X-AUTH-APIKEY"]Access-Control-Allow-Headers
CORS_HEADERS_EXPOSED["Content-Type", "x-pagination-rows-per-page", "x-pagination-current-page", "x-pagination-count-rows", "x-pagination-count-pages", "x-pagination-next", "x-request-id", "x-export-max-documents"]Access-Control-Expose-Headers. Since 2.7.1 an older default that a database stored at its first start (without x-pagination-next or x-export-max-documents) becomes this list at the start; a patched list stays
DOCS_OPENAPItrueServe the spec at /docs/docs.yaml (restart)
DOCS_SWAGGERfalseServe the Scalar API reference at /docs (restart). Since 2.7.2 a true that the Scala server stored as default becomes false at the start; a patched true stays
SERVER_HEADER_ENABLEDtrueSend the server header with name and version (2.5)
ERRORS_EXPOSE_INTERNALfalseAnswer the message of an unexpected error (500) instead of a generic one; for development (2.5). The log always has it
USERS_READ_HIDE_API_KEYtrue (3.0; false in 2.x)The document routes (list, find, search, get, export, aggregate, distinct, expand) leave out apiKey of mc_users, like password (2.6). The admin user routes keep it. false keeps the 2.x answers

Documents and filters ​

SettingDefaultDescription
AGGREGATION_STAGES_DENIED["$function", "$accumulator", "$where", "$out", "$merge", "$currentOp", "$listSessions", "$collStats", "$indexStats"]Operators refused anywhere in an aggregation pipeline. See Aggregation. Since 2.7.2 the Scala server's stored default (without $collStats and $indexStats) becomes this list at the start; a patched list stays
FILTER_TIME_ZONEUTCTime zone of dates without a zone in Lucene filters: an IANA name (Europe/Berlin) or an offset (+05:30)
IMPORT_MAX_BYTES1073741824 (1 GiB)Largest body of an import, read for every request
WATCH_MAX_STREAMS100Open live updates of one instance (each holds a change stream); 503 beyond
DOCUMENTS_CHECK_FIELD_NAMEStrue (3.2)Field names that start with $ (at any depth) or contain . (at the top level) are refused with 400 (code 4010, the paths in issues): inserts, many/insert, imports, replaces and the values of $set, $setOnInsert, $push, $addToSet. Dotted and positional update paths and $/. in values stay allowed; hooks and driver writes are not checked. checkFieldNames of a declaration wins. false stores such names as before
FILTER_OPERATORS_DENIED["$where", "$function", "$accumulator"]Operators refused anywhere in the filters, projections and updates of clients and server code (403, code 4031, 2.5). An empty list allows them

Limits ​

Since 2.5. 0 means no limit. BODY_MAX_BYTES and WATCH_QUEUE_MAX are on by default, the others are opt-in. See the production checklist. Since 2.6 every user can read them in /system/capabilities (limits), and each 413 has its own code (4131 body, 4132 upload, 4133 import).

SettingDefaultDescription
BODY_MAX_BYTES67108864 (64 MiB)Largest JSON body of a request; 413 beyond (the import has IMPORT_MAX_BYTES)
PAGING_MAX_ROWS0Largest rowsPerPage of document reads and (2.6) the file lists of buckets; a larger value reads this many, the pagination headers show it
EXPORT_MAX_DOCUMENTS0Most documents of one export, with or without limit; a capped export says so (2.6, end marker, header x-export-max-documents)
GRIDFS_UPLOAD_MAX_BYTES0Largest file of an upload; 413 beyond, the partial file is removed
WATCH_QUEUE_MAX1000Changes waiting for a slow live-update client; beyond, it gets reset and the stream ends (the client loads again and reconnects)
EXPORT_CSV_ESCAPE_FORMULASfalseA csv cell that a spreadsheet would run as a formula (=, +, -, @, tab, CR) gets a leading '

Files ​

SettingDefaultDescription
FILE_HANDLERgridfsOnly gridfs is supported (restart)
FILE_CACHE_AGE7776000max-age (seconds) of the cache-control header of downloads

Request logging and metrics ​

Off by default. A restart is required after a change. How the features are switched on per host is in Request Logging & Metrics.

SettingDefaultDescription
REQUESTLOGGING_ENABLEDfalseStandalone server: writes every request as a document into <AUTH_PREFIX>request_logging. Embedded: not read, see Switching the features on
METRICS_ENABLEDfalseStandalone server: enables /system/monitoring/* (including Prometheus text). Embedded: not read, as above
METRICS_MONGODB_DATABASEfalseDatabase statistics
METRICS_MONGODB_COLLECTIONS[]Collections with statistics
METRICS_MONGODB_CONNECTIONS, METRICS_MONGODB_NETWORK, METRICS_MONGODB_OPERATION, METRICS_MONGODB_SERVER, METRICS_MONGODB_COMMAND, METRICS_MONGODB_CONNECTIONPOOLfalseMongoDB metric groups
LOGGING_METRICS_MONGODB_STEP60mInterval of the metric snapshots
LOGGING_METRICS_MONGODB_RUNTIME, LOGGING_METRICS_MONGODB_SYSTEM, LOGGING_METRICS_MONGODB_MONGO, LOGGING_METRICS_MONGODB_EVENTfalseWrite snapshots of a category into monitoring_*

Jobs ​

SettingDefaultDescription
JOBS_ENABLEDtrueNot persistent, restart. false: this instance does not run the jobs on their schedule, but still lists them and runs them by request. Use it so that only one of several instances runs the jobs.

Migrations, seeds, files and operations (2.11) ​

SettingDefaultPersistentDescription
MIGRATIONS_ON_STARTrunnorun applies pending migrations at the start, check refuses to start with pending ones, off only registers them
SEED_ON_STARTfalse (the module: true in development)noUpsert the seeds at the start
FILE_LINK_MAX_DURATION7dyesLongest lifetime of a signed file link
OTEL_ENABLEDfalsenoCommand monitoring for the tracing; the standalone server switches tracing() on and exports over OTLP
OTEL_HASH_USER_IDtrueyes, restartThe user id of a span as SHA-256 (16 hex digits)
RATE_LIMIT_LOGIN10/15m (3.0; 2.x: empty, off)yesFailed logins (/auth/login, Basic auth) per user and address, like 10/15m; then 429 with Retry-After; empty switches it off
RATE_LIMIT_REQUESTSempty (off)yesRequests per verified user, like 600/1m; requests without credentials, and those whose credentials fail, count for their address (3.0: unverified credentials no longer pick the counter)
RATE_LIMIT_STOREmemoryyes, restartmemory per instance, mongo shared by the instances (mc_rate_limits, TTL)
RATE_LIMIT_TRUSTED_PROXIES[]yesAddresses of proxies whose X-Forwarded-For is read for the client address
BACKUP_COLLECTIONS[] (declared and mc_*)yesCollections of a backup
BACKUP_DIRECTORY— (bucket mc_backups)yesDirectory for the backups instead of the bucket
BACKUP_RETENTION7yesBackups that are kept (newest)
AUTH_SESSIONSfalseyes, restart3.0: sessions with rotating refresh tokens (httpOnly cookie)
AUTH_SESSION_DURATION30dyes3.0: lifetime of a session
AUTH_REGISTRATIONoffyes, restart3.0: open or invite self-registration
AUTH_REGISTRATION_ROLES[]yes3.0: roles of an open registration
AUTH_REQUIRE_VERIFIED_EMAILfalseyes3.0: no login with an unverified address
AUTH_PASSWORD_RESETfalseyes, restart3.0: password reset by mail
AUTH_PASSWORD_MIN_LENGTH8yes3.0: registration and reset
AUTH_APP_URLempty (origin of the request)yes3.0: base of the links in the mails
AUTH_VERIFY_DURATION, AUTH_RESET_DURATION, AUTH_INVITE_DURATION24h, 1h, 7dyes3.0: lifetime of the tokens
AUTH_PASSWORDLESSfalseyes, restart3.0: login by link or code
AUTH_PASSWORDLESS_DURATION15myes3.0: lifetime of a login link
QUEUE_WORKERtrueyes3.0: this instance works on the job queue (when it has handlers)
QUEUE_CONCURRENCY1yes3.0: jobs at once per instance
QUEUE_LEASE60syes3.0: lease of a claimed job, renewed while it runs
QUEUE_POLL_INTERVAL1syes3.0: how often an idle worker looks for due jobs
QUEUE_KEEP_DONE7dyes, restart3.0: done jobs are removed after this time
WEBHOOKS_ALLOW_PRIVATEfalseyes3.0: webhooks may call internal addresses
WEBHOOKS_DISABLE_AFTER10yes3.0: failed deliveries in a row before a webhook is switched off (0: never)
WEBHOOKS_TIMEOUT10syes3.0: time for the answer of a receiver
OUTBOX_INTERVAL30syes, restart3.0: how often the outbox of transactions is checked for events a stopped server did not publish
MCP_MAX_ROWS100yes3.0: documents per answer of the MCP endpoint
MCP_MAX_BYTES100000yes3.0: text per answer of the MCP endpoint
RESPONSE_COMPRESSIONfalseyes3.0: gzip (or deflate) of JSON, YAML, text, CSV and NDJSON answers when the request accepts it; streams are compressed as they are read. A large page shrinks about 14 times at no measurable cost; leave it off behind a proxy that compresses

Migration ​

SettingDefaultDescription
MIGRATION_DROP_SCALA_LEFTOVERSfalseNot persistent. Set it for one start when upgrading the database of an older MongoCamp server; what it changes is described in Migration to 2.0. Running it again changes nothing.

Released under the MIT License.