Environment variables
This page lists every environment variable MicroB2B reads. They hold what MicroB2B needs before it can open its database. Everything else is stored in the database and changed in the web UI or the REST API.
Some settings are not environment variables:
- Where message contents are stored, and other global settings, are in System > Settings. See settings.
- Ports, directories and retry settings of receivers, senders and other parts are in their own configuration in the web UI.
Variables take effect when MicroB2B starts. After a change, restart MicroB2B.
For a key, you can give the value itself or, with the _FILE variant, the path of a file that holds it. Give one of the two, never both.
Required
| Variable | What it does | Default |
|---|---|---|
PUBLIC_URL | The address users reach MicroB2B at, such as https://b2b.example.com. HTTPS, no path. http only for localhost, 127.0.0.1 and ::1 | none, required |
SESSION_KEY, SESSION_KEY_FILE | Key of the sign-in cookies. Base64 or hex of at least 32 random bytes | none, required |
SECRETS_KEY, SECRETS_KEY_FILE | Master key of stored secrets and private keys. Base64 or hex of exactly 32 random bytes | none, required |
See required settings for how to generate them.
Sign-in
| Variable | What it does | Default |
|---|---|---|
SESSION_TTL | How long a sign-in lasts, from 5m to 72h | 8h |
Database
| Variable | What it does | Default |
|---|---|---|
DB_TYPE | sqlite3 or postgres | sqlite3 |
DB_URL | Where the database is | file:microb2b.db |
DB_MAX_OPEN_CONNS | PostgreSQL only: most open connections. 0 means no limit | 25 |
DB_MAX_IDLE_CONNS | PostgreSQL only: idle connections kept. At most DB_MAX_OPEN_CONNS | 10 |
DB_CONN_MAX_LIFETIME | PostgreSQL only: close a connection after this age. 0 means never | 30m |
DB_CONN_MAX_IDLE_TIME | PostgreSQL only: close a connection idle this long. 0 means never | 5m |
BUNDEBUG | 1 or 2 logs every SQL statement. Needs LOG_LEVEL=debug. Failed statements are always logged | not set |
See database.
Web server
| Variable | What it does | Default |
|---|---|---|
HTTP_PORT | Port of the web UI and REST API, on every interface | 8080 |
ALLOWED_ORIGINS | Other websites whose pages may call the REST API from a browser. Comma-separated, or * for all | empty: none |
See reverse proxy.
Secrets and audit log
| Variable | What it does | Default |
|---|---|---|
SECRETS_PREVIOUS_KEYS, SECRETS_PREVIOUS_KEYS_FILE | Earlier master keys while you replace SECRETS_KEY. Separated by commas, spaces or new lines | not set |
AUDIT_KEY, AUDIT_KEY_FILE | Makes the audit log tamper-evident. Base64 or hex of at least 32 random bytes | not set: no hashes |
MicroB2B refuses to start with an unknown variable that starts with SECRETS_ or AUDIT_. That catches typing errors. See secrets and audit log.
S3 payload storage
| Variable | What it does | Default |
|---|---|---|
AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY | Credentials for S3 payload storage | not set |
MicroB2B finds S3 credentials the way every AWS tool does. Instead of these variables, you can use the AWS credentials file or a role of the server. The bucket itself is a setting in System > Settings. See payload storage.
Logging
| Variable | What it does | Default |
|---|---|---|
LOG_LEVEL | debug, info, warn or error. Anything else means info | info |
LOG_STREAM_LEVEL | Lowest level on the Logs page and in the OpenTelemetry export. Cannot be below LOG_LEVEL | info |
OpenTelemetry
| Variable | What it does | Default |
|---|---|---|
OTEL_ENABLED | true sends traces, metrics and logs | false |
OTEL_EXPORTER_OTLP_ENDPOINT | Where to send them, host:port, over gRPC with TLS | localhost:4317 |
OTEL_EXPORTER_OTLP_INSECURE | true sends without TLS | false |
OTEL_EXPORTER_OTLP_HEADERS | Headers for every export, key=value,key2=value2. For Uptrace: uptrace-dsn=<DSN> | not set |
OTEL_SERVICE_NAME | Name MicroB2B reports itself as | microb2b |
OTEL_SERVICE_VERSION | Version it reports | the program’s version |
See monitoring.
Which commands read what
microb2b standalonereads all of the above.microb2b usersandmicrob2b service-accountsread the database variables.microb2b usersalso readsPUBLIC_URL, to print whole setup links.microb2b secretsreads the database variables and theSECRETS_*variables.microb2b auditreads the database variables and theAUDIT_*variables.
See the command line.