Running BxLens in production
On this page
Running BxLens in production
The bar is a development tool. The console can run on a live server if you set it up with care. This guide is the checklist, then the reasons. Pages for the rest of the job: Several servers, Backup, retention and disk usage, Hardening and threat model and the Alert runbook.
Work down it once per environment.
A safe boxlang.json to copy.
15 steps with the reasons.
Prove it from a machine that is not allowed.
What changes in production
That makes three choices important: who may reach it, what is collected, and what the bar does.
When the console is on, BxLens collects every request on the server, not only those from allowed callers, so the console can show real traffic. Only people who pass the access rule and sign in can read it.
The checklist
Work down the list once per environment. Each line says where to set it. The sections after it give the detail. Items marked "(boxlang.json only)" cannot be set in the console.
-
bar.enabledisfalse(boxlang.json, or Settings on the console). -
console.enabledistrue, with a password that is not in a file you commit (boxlang.json, or Settings, Security). -
console.accessnames a VPN range or a few addresses, not"all"(boxlang.jsononly). -
console.requireHttpsistrue, and the runtime sees the request as HTTPS (boxlang.jsononly). -
access.allowedHostslists the host name people type. Behind a proxy,access.proxyPeerslists the proxy addresses, not the whole private network (boxlang.jsononly). -
collect.levelislight(the default). - Operators who only look have the viewer password (BoxLang+). Everyone else has no password.
-
console.readOnlyistrueif nobody should change anything from the console, andconsole.actionsisfalseif nobody should run tasks, clear caches or restart applications from it (boxlang.jsononly). -
console.allowHeapDumpisfalse(the default). -
ai.enabledisfalse, or the provider is a model inside your network. - With BoxLang+:
store.diris on a volume that outlives the server, every server has a stablestore.instanceFolder(orBXLENS_INSTANCE_FOLDER), andstore.retentionDaysandstore.maxMBare what you want to keep. -
secrets.diris on a shared volume when several servers must read the same secrets, andBXLENS_SECRETS_KEYis set on every server if the key must stay off that volume. - The folders in Backup, retention and disk usage are in your backup, and the key is not in the same backup as the data.
- You read
bxlens-audit.lognow and then, or ship it with your other logs. - You tried the checks at the end of this page from a machine that is not allowed.
A safe starting point
{
"modules": {
"bxLens": {
"settings": {
"bar": { "enabled": false },
"console": {
"enabled": true,
"password": "bxsecret:AbCdEf123...==",
"viewerPassword": "bxsecret:GhIjKl456...==",
"requireHttps": true,
"access": [ "10.8.0.0/24" ],
"sessionMinutes": 15,
"actions": false,
"readOnly": true,
"allowHeapDump": false,
"publicUrl": "https://ops.example.com/~bxlens/index.bxm"
},
"collect": { "level": "light" },
"access": {
"allowedHosts": [ "ops.example.com" ],
"trustProxyHeader": true,
"proxyHeader": "X-Forwarded-For",
"proxyPeers": [ "10.0.1.5" ]
},
"store": {
"dir": "/mnt/lens-store",
"instanceFolder": "web-a",
"retentionDays": 15,
"maxMB": 500
},
"secrets": { "dir": "/mnt/lens-secrets" },
"ai": { "enabled": false },
"history": { "maxRequests": 100 }
}
}
}
}
"password": "${env.BXLENS_PASSWORD}"
Check that the variable is set: an unset placeholder stays as literal text.
Run boxlang generatesecret "a long random password" and paste the bxsecret: value into console.password. Do the same, with another password, for console.viewerPassword. Pin the seed with BOXLANG_SECURITY_SECRETSEED if several machines share one config, see Set passwords: plain, env or bxsecret.
Leave both out of the file and set the passwords in the console after a first start with a throwaway password. The console value wins, and the page says where each password comes from.
readOnly: true and actions: false suit a console that is only for looking. Take them out when your operators need to change settings, set passwords in the console or run tasks from it. With readOnly on, a password cannot be changed from the console either: the operator edits boxlang.json.
console.publicUrl is the address people reach the console at. It gives the "Open in BxLens" link in the mails and in the messages sent to Slack, Teams, Telegram and webhooks. Leave it empty if you want no link.
What goes in boxlang.json and what in the console
console.enabled, console.access, console.requireHttps, console.readOnly, console.actions, console.allowHeapDump, console.sessionMinutes, console.publicUrl, console.overridesFile, all of access.*, bar.access, every store.*, secrets.dir, notifications.channelHosts, registration.*, server.*, async.*. A change needs a restart.
Admin only, stored in the Secret Store. The admin and viewer passwords (the viewer login is BoxLang+), the AI key and the SMTP password (write only, BoxLang+). They win over boxlang.json.
BoxLang+ to change. collect.level, bar.enabled, thresholds, collector switches, UI, limits, ai.* except the key. Saved in config/bxlens-settings.json and loaded at the next start. They win over boxlang.json.
BoxLang+. The SMTP server, recipients, alert rules, channels, report schedule. Saved in the store, so they reach every server.
A rule of thumb: what decides who can get in and what the server may delete stays in boxlang.json, where a deploy controls it. What an operator tunes on a bad day goes in the console. The full lists are in Live settings.
Step by step
- Keep the passwords out of the file. Use an environment variable (
"password": "${env.BXLENS_PASSWORD}") or an encrypted value. For the encrypted value runboxlang generatesecret "a long random password"and paste thebxsecret:value intoconsole.password. Do the same, with another password, forconsole.viewerPassword. Pin the seed withBOXLANG_SECURITY_SECRETSEEDif several machines share one config, see Set passwords: plain, env or bxsecret. Never commit a plain text password. Check that the variable is set, an unset placeholder stays as literal text. Or leave both out of the file and set the passwords in the console after a first start with a throwaway password: the console value wins, and the page says where each password comes from. - Give people the right role. Operators who only look use the viewer password (BoxLang+). A viewer cannot change anything, cannot download dumps, logs or the bundle, and does not get the Logs, Environment, System and Threads pages or the admin tabs of Settings, but can still read request data and queries, so keep the password private. See Roles.
- Limit who can reach it. Set
console.accessto a VPN range or a short list of IPs and CIDRs. Keep"local"if you tunnel in with SSH. Avoid"all": it works, but BxLens logs a warning. Addaccess.allowedHostsfor the host name you use (alocalrule otherwise accepts onlylocalhost,127.0.0.1and[::1]as Host names), andaccess.requireHeaderif a proxy can add a secret header. A caller who is not allowed gets a plain 404. - Use HTTPS and require it. Set
console.requireHttpstotrue. Terminate TLS in front of the runtime and make sure the runtime sees the request as secure: either it reports HTTPS itself, or your proxy sendsX-Forwarded-Proto: httpsfrom an address inaccess.proxyPeers. Check the cookie in your browser tools (it must be Secure). Loopback callers are exempt, so an SSH tunnel to the server still works over HTTP. - Say which proxies to trust. Behind a proxy or load balancer, set
access.proxyPeersto the addresses of your proxies, not the whole private network, so only they can name the client address. Without a proxy, setaccess.trustProxyHeadertofalse. The lockout andconsole.accessuse this address, so a wrong setting locks out everyone behind the proxy, or lets a caller choose their own address. See Behind a proxy. - Collect lightly.
collect.level: "light"skips request headers, bound query parameters, the caller (template and line) of queries, HTTP calls and transactions, the BoxLang frames of exceptions, scope contents, Java stack traces, and thefunctions,logs,scopesandbifscollectors. SQL text, timings and counts stay. It is the default. Non HTML requests are not kept in the history (history.trackNonHtml), and the history is built lazily, so a request nobody opens costs no snapshot. Usefullonly on a machine you control. Leavecollectors.queries.includeParamsoff: bound values can be personal data. - Turn the bar off. Leave
bar.enabledfalse. Developers do not need a strip injected into live pages. - Decide on changes. Set
console.actionstofalseif nobody should run, pause or reload tasks, clear caches, restart applications, start or stop watchers or requeue mail from here (most of these also need BoxLang+). Setconsole.readOnlytotrueif nobody should change anything from the console. The pages stay readable. - Keep heap dumps off. Heap dumps need BoxLang+ or a trial. Leave
console.allowHeapDumpatfalse. A heap dump holds every secret in memory. Turn it on for the time you need it, then off. See Heap dumps. - Decide on AI. Leave
ai.enabledfalse, or use a local provider so prompts stay in your network. See AI data flow. - Put the store on a volume. With BoxLang+ or a trial, errors, reports and the notification settings are saved to
store.dir. In a container, mount a volume there, or the data is lost when the container is replaced (BxLens logs a warning when it sees the folder on the container's own file system). Give each server a stable name withstore.instanceFolderorBXLENS_INSTANCE_FOLDER. Setstore.retentionDaysandstore.maxMBto what you want to keep. See The store and Backup, retention and disk usage. - Hide what you do not need.
tabs.hideremoves pages, for example["threads", "designer", "environment"]. - Size the history.
history.maxRequestsis the memory you spend. Each request holds its full snapshot in memory. On Free the history is capped at 25. Watch the heap on the System page after you raise it. - Watch the audit log.
bxlens-audit.login the logs directory records logins, failed logins, denied attempts and every change. Read it on the Logs page or ship it with your other logs. The Security alert (BoxLang+) mails you when failed logins pile up. - Set up alerts. With BoxLang+, switch on the alerts you need in Settings, Notifications, after you have a feel for the normal numbers. The Alert runbook says what each one means and what to check.
What is bounded in memory
Every store has a hard cap and drops the least recently seen entry. This is what you budget for.
| What | Cap |
|---|---|
| Request history | history.maxRequests (default 250, 25 on Free). The only large one: it holds full snapshots |
| Query statistics | 500 statements |
| Error issues | 200 issues, 5 events each, 20 new kinds a minute, 1000 events a second. See errors in a flood |
| Report URLs | 300 |
| Outgoing HTTP calls list | 500 calls, at collect.level full |
| Mail messages | collectors.mail.maxMessages (200), 10 on Free |
| AI runs | collectors.aiobs.maxRuns (500) |
| Cache keys on the Caches page | 100 per cache, values cut at 2 KB |
| Log lines per read | 2000 |
| Console sessions | 200 |
| Live streams | console.maxStreams (10) |
| Background work queue | async.queueSize (2000 tasks), then new work is dropped and counted |
| Disk writes queue | store.queueSize (20000 records), then new records are dropped and counted |
Disk is covered in Backup, retention and disk usage. The figures for the time a request costs are in Performance, and how it behaves under heavy traffic and error floods is in Performance under load.
Work off the request thread
The files of the bar
The console URL
/~bxlens/index.bxm always works. Lens also rewrites /~bxlens and /~bxlens/ (with the trailing slash) to it, in onWebExecutorRequest. Nothing else in the public folder becomes reachable that way.
On MiniServer the request must also pass the pass predicate, or MiniServer serves it as a static path and never hands it to BoxLang. Add the console path to the default predicate, in one of two ways.
Set BOXLANG_PASS_PREDICATE to this exact value:
regex( '^(/.+?\.cfml|/.+?\.cf[cms]|.+?\.bx[ms]{0,1})(/.*)?$' ) or regex( '^/~bxlens/?$' )
Set the same string as passPredicate in miniserver.json (in JSON, write each backslash twice).
The first regex is the default MiniServer predicate and the second one lets the console path through.
MiniServer welcome files do not apply to module mappings, and the list of welcome files is not configurable in core. That is why Lens does the rewrite itself.
On CommandBox or a servlet container this was not tested. The trailing slash form works only if the path reaches the BoxLang servlet, which depends on the server's own mappings. Use /~bxlens/index.bxm there.
Check it
- Request
/~bxlens/index.bxmfrom a machine that is not allowed. You get a plain 404. - Request it over plain HTTP from an allowed non-loopback machine. You get a 403 with
HTTPS is required for the console. - Request it from an allowed machine over HTTPS. You see the login page.
- Sign in with the viewer password and try to change a setting. The fields are disabled, and a direct call gets a 403.
- The Settings page shows the passwords as
set,collect.levelaslightandconsole.readOnlyas true. - The log shows
bx-lens ... active: bar=false, console=true, collect=light. - After a restart, the Reports page still shows "Since first install" (needs BoxLang+ or a trial).
Performance and overhead
Know the limits
The console is for one server. It keeps recent requests, query statistics and in-flight data in memory and loses them at a restart. With BoxLang+ or a trial, errors and reports survive restarts. For several nodes that share a store folder, BoxLang+ adds a server selector and alerts, see Several servers.
See also Security.