Skip to content

Configuration

Every variable the server reads, what it defaults to, and what happens when it is unset.

.env.example in the repository is the complete inventory: every variable, once, with what reads it. If a variable is not in that file, nothing reads it. This page is the tour.

docker compose reads .env automatically. So does cargo run, through dotenvy. Keep it out of version control: it holds the key every other key is derived from.

Required

sh
MICAFORGE_SECRET_KEY_BASE=   # openssl rand -base64 48
POSTGRES_PASSWORD=           # openssl rand -hex 24
CLICKHOUSE_PASSWORD=         # openssl rand -hex 24
MICAFORGE_DOMAIN=:80
ACME_EMAIL=

MICAFORGE_SECRET_KEY_BASE is the one operator secret. Session cookies, sealed credentials, share-link signatures and the ingest HMAC are all derived from it. Rotating it logs everyone out and makes stored secrets unreadable. 32 characters minimum, refused at boot below that.

MICAFORGE_DOMAIN is read by Caddy. A hostname turns on automatic HTTPS; the literal :80 serves plain HTTP, which is what you want on a laptop or behind a proxy that terminates TLS already.

Keep the two store passwords to characters that need no percent-encoding: they are interpolated into connection URLs. Hex is the safe choice and is what the installer generates.

Public addresses

sh
MICAFORGE_PUBLIC_URL=https://analytics.example.com
MICAFORGE_DASHBOARD_URL=https://analytics.example.com

Both must be addresses a browser can reach, not the address the server binds. They are printed into invitation emails, share links and the tracking snippet, so a wrong value here is a snippet that silently sends nothing. They are two variables because a managed install can serve the dashboard from a CDN and the API from elsewhere.

Stores

In the shipped compose file the three connection URLs are assembled from the parts and the container names, so there is nothing to set beyond the passwords. Spelled out, for a local cargo run:

sh
MICAFORGE_DATABASE_URL=postgres://micaforge:[email protected]:5432/micaforge
MICAFORGE_CLICKHOUSE_URL=http://127.0.0.1:8123
MICAFORGE_CLICKHOUSE_DB=micaforge
MICAFORGE_CLICKHOUSE_USER=micaforge
MICAFORGE_CLICKHOUSE_PASSWORD=
MICAFORGE_REDIS_URL=redis://127.0.0.1:6379

ClickHouse takes its database and credentials separately rather than folded into the URL, because the driver does. Valkey speaks the Redis wire protocol, so the scheme stays redis://.

Postgres memory is tuned for a 4 GB machine shared with ClickHouse: POSTGRES_SHARED_BUFFERS, POSTGRES_EFFECTIVE_CACHE_SIZE, POSTGRES_WORK_MEM, POSTGRES_MAX_CONNECTIONS. On a bigger box, raise shared buffers to about a quarter of RAM and effective cache size to about half.

Behaviour

sh
MICAFORGE_BIND_ADDR=0.0.0.0:8080
MICAFORGE_DISABLE_REGISTRATION=true
MICAFORGE_SELF_HOSTED=true
MICAFORGE_LOG_FORMAT=json
MICAFORGE_WORKER_CONCURRENCY=2
MICAFORGE_WRITER_BUFFER_MB=32
RUST_LOG=info

Registration is closed by default. The first account on an install is always allowed and becomes its owner; everyone after it joins by invitation, unless you set MICAFORGE_DISABLE_REGISTRATION=false. There are no passwords: every account signs in with a six-digit code sent to its address, and an invitation is what lets a new address be sent one while registration is closed.

An install that lets anybody sign up can bound what one account brings with MICAFORGE_MAX_SITES_PER_ORG and MICAFORGE_MAX_ORGS_PER_USER. Both default to 0, which means no limit, and neither applies to an instance admin.

MICAFORGE_WRITER_BUFFER_MB is how much each event table may hold in memory while ClickHouse is away, for a restart or an upgrade. The server keeps retrying and loses nothing until the buffer is full; then it drops the oldest rows and logs how many. Six tables, so the worst case is six times the value.

MICAFORGE_SELF_HOSTED gates no feature, because there are none to gate. It selects the admin surface and guarantees no outbound call at runtime.

MICAFORGE_WORKER_CONCURRENCY is how many background jobs run at once: crawls, imports, scheduled reports, alert evaluation. Two is right for a 4 GB VPS, where the ingest path must not queue behind an import. It defaults to half the cores, minimum 2, maximum 16.

Retention

sh
MICAFORGE_RETENTION_DAYS=0
MICAFORGE_REPLAY_RETENTION_DAYS=30

0 means forever, and forever is the default: an analytics tool that quietly deleted history because a variable was unset would be indefensible. See data retention.

Geography, off by default

Micaforge makes no outbound call to resolve an address, so geography needs a database on disk. Drop a MaxMind-compatible .mmdb into infra/geoip/ and point these at the path inside the container:

sh
MICAFORGE_GEOIP_CITY_PATH=/geoip/GeoLite2-City.mmdb
MICAFORGE_GEOIP_ASN_PATH=/geoip/GeoLite2-ASN.mmdb

Behind Cloudflare, with MICAFORGE_TRUSTED_PROXY_HEADER=cf-connecting-ip, an install with no city database takes the visitor’s country from Cloudflare’s CF-IPCountry header, and the region, city and coordinates too when the zone has Cloudflare’s “Add visitor location headers” managed transform turned on. The same trust that names the visitor’s address names their location; the database, when there is one, still wins.

Without either, you get no geography at all. Without the ASN database there is no datacenter detection, which weakens agent verification without breaking it, since user-agent patterns and reverse DNS still apply.

Mail, off by default

Two ways to send it. Cloudflare Email Sending, over its HTTPS API:

sh
MICAFORGE_CLOUDFLARE_EMAIL_TOKEN=     # an API token allowed to send email
MICAFORGE_CLOUDFLARE_ACCOUNT_ID=      # the account the token sends for
MICAFORGE_MAIL_FROM=Micaforge <[email protected]>

Or any SMTP relay:

sh
MICAFORGE_SMTP_URL=smtp://user:[email protected]:587
MICAFORGE_MAIL_FROM=Micaforge <[email protected]>

Cloudflare wins when both of its variables are set, then SMTP, then nothing. Setting only one of the two Cloudflare variables stops the server at boot and names the one that is missing, rather than quietly falling back. The From address must be on a domain your provider lets you send from.

With no transport every email path degrades instead of failing: invitations become links you copy from the dashboard, scheduled reports do not run, and a sign-in code is one the operator prints on the host:

sh
docker compose exec micaforge micaforge-server sign-in-code [email protected]

It prints a code only for an address that may sign in, the same rule the sign-in screen follows. The code works once, expires in ten minutes, and replaces any code sent to that address before. No code, link or token is ever written to the log, because anyone who can read a log could otherwise take over the account.

Google and GitHub sign-in, off by default

sh
MICAFORGE_GOOGLE_CLIENT_ID=
MICAFORGE_GOOGLE_CLIENT_SECRET=
MICAFORGE_GITHUB_CLIENT_ID=
MICAFORGE_GITHUB_CLIENT_SECRET=

Each pair adds a Continue with button to the sign-in screen, beside the emailed code. Set both halves of a pair or neither; one half alone stops the server at boot. Register MICAFORGE_PUBLIC_URL + /api/auth/oauth/google/callback (or /github/callback) with the provider. Google and GitHub sign-in has the steps.

Billing, off by default

sh
MICAFORGE_BILLING_ENABLED=false
MICAFORGE_BILLING_PLANS=              # JSON list of plans, required when billing is on
MICAFORGE_STRIPE_SECRET_KEY=          # optional, with the webhook secret
MICAFORGE_STRIPE_WEBHOOK_SECRET=

For an operator who sells Micaforge as a service. Leave it off on your own install. When it is on, each organisation’s plan sets its event quota and its site and member limits, and the plan’s site limit replaces MICAFORGE_MAX_SITES_PER_ORG. The Stripe keys are read only while billing is on, and both or neither must be set. Billing, for operators has the plan format and the Stripe setup.

Images and ports

sh
MICAFORGE_IMAGE=micaforge            # or ghcr.io/loruorg/micaforge
MICAFORGE_WEB_IMAGE=micaforge-web    # or ghcr.io/loruorg/micaforge-web
MICAFORGE_VERSION=local              # or a release, such as 0.1.0
POSTGRES_IMAGE=postgres:17-alpine
CLICKHOUSE_IMAGE=clickhouse/clickhouse-server:26.8-alpine
VALKEY_IMAGE=valkey/valkey:8-alpine
HTTP_PORT=80
HTTPS_PORT=443

With bare image names the server and web images are built from your checkout. With a registry path they are pulled, at MICAFORGE_VERSION. ./install.sh --version 0.1.0 sets all three for you.

The stores are pinned to a major version (Postgres, Valkey) or an LTS line (ClickHouse), so a pull brings patch releases and never a format change. ClickHouse cannot be downgraded once it has written data: move that line on purpose, after ./backup.sh.

Moving HTTP_PORT off 80 breaks certificate issuance: ACME’s HTTP-01 challenge needs port 80 reachable on the standard port.

Who the visitor is

sh
MICAFORGE_TRUSTED_PROXIES=                 # read by Caddy
MICAFORGE_TRUSTED_PROXY_HEADER=x-real-ip   # read by the server; set in docker-compose.yml

The visitor address feeds the daily visitor hash and the rate limits, and is never stored. Caddy writes the address it resolved into X-Real-IP, overwriting any a client sent, and the server believes that header and nothing else.

MICAFORGE_TRUSTED_PROXIES is who Caddy believes when they say who the visitor is. Empty trusts nobody, which is right when Caddy faces the internet. Behind your own proxy on the same network, set private_ranges; behind a CDN, list the CDN’s published ranges, space separated. Get it wrong and every visitor arrives with the proxy’s address, so they all count as one visitor and share one rate-limit bucket.

Hardening and limits

sh
MICAFORGE_ADMIN_EMAILS=                 # extra instance admins, comma separated
MICAFORGE_RATE_LIMIT_PER_MIN=3000       # per client address, 0 switches it off
MICAFORGE_CORS_ORIGINS=                 # extra dashboard origins, comma separated
MICAFORGE_ALLOW_PRIVATE_OUTBOUND=false  # let webhooks reach your own network

The first registered account is always an instance admin. An address in MICAFORGE_ADMIN_EMAILS becomes one only after its owner verifies it, which every code sign-in does.

Outbound requests (robots.txt and sitemap reads, webhooks, imports by URL) refuse private, loopback and link-local addresses, after DNS and on every redirect, so a site record cannot be pointed at your database or a cloud metadata endpoint. Turn MICAFORGE_ALLOW_PRIVATE_OUTBOUND on only if your webhooks really go to a host on your own network.

Monitoring and growth

sh
MICAFORGE_REGION=default     # the probe region label on every uptime check
MICAFORGE_LINKS_HOST=        # a bare hostname that serves short links, such as go.example.com

MICAFORGE_REGION is the probe region label written on every uptime check. One install checks from one place, so the label names that place. It is stored on every check so that a later install that checks from more than one place can tell the results apart. Any short name will do: letters, digits, - and _, up to 32 characters. Anything else is refused at boot, by name.

Uptime checks are outbound requests. They go through the same guard as webhooks, and MICAFORGE_WORKER_CONCURRENCY caps how many run at once. An install with no monitor makes none.

MICAFORGE_LINKS_HOST is a hostname that also serves short links at its root, such as https://go.example.com/<slug>. The scheme follows MICAFORGE_PUBLIC_URL. Give the bare hostname: a scheme, a port or a path is refused at boot. Unset, short links are served only at <API origin>/l/<slug>. A host here also needs DNS that points at the server and, in the compose stack, its own site block in the Caddyfile; the short links page has the block.

The web app

The shipped web image needs no build-time configuration: the dashboard calls the API on whatever address served it. Two Astro variables exist for other setups, and both are read at build time:

sh
PUBLIC_API_URL=https://api.example.com   # only when the dashboard is on another origin
PUBLIC_SITE_URL=https://micaforge.com    # canonical address of the marketing pages

AI analyst, off by default

sh
MICAFORGE_LLM_BASE_URL=          # https://api.openai.com/v1, or http://ollama:11434/v1
MICAFORGE_LLM_MODEL=             # required with the base URL
MICAFORGE_LLM_API_KEY=           # optional; a local server usually needs none
# MICAFORGE_LLM_TIMEOUT_SECS=45  # per model call, 5 to 120
# MICAFORGE_LLM_DAILY_LIMIT=0    # questions per organisation per UTC day, 0 = no limit

One model serves every AI feature: Ask AI, the explanations on investigations, the MCP ask tool and the chat apps. Any endpoint that speaks the OpenAI chat/completions format with tool calling will do, hosted or on your own network: the server posts to MICAFORGE_LLM_BASE_URL followed by /chat/completions.

The base URL and the model turn it on, and they go together: setting one without the other stops the server at boot and names the one that is missing. The key, the timeout and the limit mean nothing without an endpoint, so setting any of them with no base URL stops the boot too, naming MICAFORGE_LLM_BASE_URL, which is why the two defaults above are commented out. The base URL must be an absolute http or https address. The key is sent as a bearer token and is never logged.

The model’s address is configuration you wrote, not input a user typed, so the private-address rule that guards webhooks does not apply to it: a model server on your own network, such as http://ollama:11434/v1 in the same compose project, works without MICAFORGE_ALLOW_PRIVATE_OUTBOUND.

MICAFORGE_LLM_TIMEOUT_SECS bounds one call to the model, not a whole answer, which may take several calls. Outside 5 to 120 the server refuses to start.

MICAFORGE_LLM_DAILY_LIMIT counts questions per organisation per UTC day, across the dashboard, MCP, the chat apps and the investigation explanations. Past it, every surface answers that the limit is reached until midnight UTC.

With the base URL unset, no AI feature makes a call. The dashboard says AI is off, investigations open with their statistical findings only, and nothing is sent to a model. What is sent when it is on is listed in Ask AI.

Chat apps, off by default

sh
MICAFORGE_SLACK_SIGNING_SECRET=        # Basic Information → App Credentials
MICAFORGE_SLACK_BOT_TOKEN=             # xoxb-…
MICAFORGE_DISCORD_APPLICATION_ID=
MICAFORGE_DISCORD_PUBLIC_KEY=          # 64 hex characters
MICAFORGE_DISCORD_BOT_TOKEN=
MICAFORGE_TELEGRAM_BOT_TOKEN=          # from BotFather
MICAFORGE_TELEGRAM_WEBHOOK_SECRET=     # 1 to 256 of A-Z a-z 0-9 _ -

Each platform is on when all of its variables are set and off when none are. Half a platform is refused at boot, with the missing variable named, rather than left to fail every request with a signature error nobody can trace back to a typo:

Platform Variables, all or none
Slack MICAFORGE_SLACK_SIGNING_SECRET, MICAFORGE_SLACK_BOT_TOKEN
Discord MICAFORGE_DISCORD_APPLICATION_ID, MICAFORGE_DISCORD_PUBLIC_KEY, MICAFORGE_DISCORD_BOT_TOKEN
Telegram MICAFORGE_TELEGRAM_BOT_TOKEN, MICAFORGE_TELEGRAM_WEBHOOK_SECRET

Two values are checked for shape at boot as well: the Discord public key must be the 64-character hex key from the developer portal, and the Telegram secret must be 1 to 256 characters of A-Z, a-z, 0-9, _ and -, which is what Telegram accepts.

These are one set per install. Which channel answers for which site is not configuration: a member links it from the dashboard with a one-time code. Creating each app, step by step, is in Slack, Discord and Telegram.

Two setup commands run on the host once the variables are in place:

sh
docker compose exec micaforge micaforge-server chat-setup discord    # registers /micaforge
docker compose exec micaforge micaforge-server chat-setup telegram   # sets the webhook and the commands

Feedback channel, off by default

sh
MICAFORGE_FEEDBACK_WEBHOOK_URL=        # a Slack incoming webhook, or a Discord webhook
MICAFORGE_FEEDBACK_TELEGRAM_CHAT_ID=   # a chat the install's Telegram bot posts to

New feedback is always emailed to every instance admin when the install sends mail. These two add a channel beside the inbox, and both are optional.

MICAFORGE_FEEDBACK_WEBHOOK_URL takes a Slack incoming webhook, or any endpoint that accepts the same JSON body, or a Discord webhook, which is recognised by its discord.com or discordapp.com host. It must be an http or https address.

MICAFORGE_FEEDBACK_TELEGRAM_CHAT_ID sends each report to that chat with the install’s own Telegram bot, so it needs MICAFORGE_TELEGRAM_BOT_TOKEN, and with it the rest of the Telegram pair. Set without the bot token, it stops the boot and names MICAFORGE_TELEGRAM_BOT_TOKEN.

Google Search Console, off by default

sh
MICAFORGE_SEARCH_CONSOLE_CLIENT_ID=
MICAFORGE_SEARCH_CONSOLE_CLIENT_SECRET=

The pair lets a site admin connect a Google Search Console property, so the Search screen shows the search terms, pages, countries and devices Google reports for the site. Set both or neither; one alone stops the server at boot. With neither, no site can connect and Micaforge makes no call to Google.

It is a Google Cloud OAuth client of type Web application, in a project with the Google Search Console API turned on, with MICAFORGE_PUBLIC_URL + /api/search-console/callback registered as a redirect address. It is a separate pair from the sign-in client above because Search Console needs the webmasters.readonly scope, which Google reviews, while sign-in uses only scopes Google does not. You may paste the same client into both pairs if you register both redirect addresses on it. Google Search Console has the steps.

GitHub App, off by default

sh
MICAFORGE_GITHUB_APP_ID=               # the numeric App ID
MICAFORGE_GITHUB_APP_SLUG=             # the name in github.com/apps/<slug>
MICAFORGE_GITHUB_APP_PRIVATE_KEY=      # the .pem GitHub generated; line breaks may be written as \n
MICAFORGE_GITHUB_APP_WEBHOOK_SECRET=   # the webhook secret you gave the App
MICAFORGE_GITHUB_APP_CLIENT_ID=        # the App's own client ID (not MICAFORGE_GITHUB_CLIENT_ID)
MICAFORGE_GITHUB_APP_CLIENT_SECRET=    # a client secret generated on the App's page

The GitHub App puts each site’s deploys, releases and pushes on its charts as annotations, and opens feedback as GitHub issues. Set all six or none; part of the group stops the boot and names the first missing variable. The App ID must be a number, the slug lower-case letters, digits and hyphens, and the private key an RSA key in PEM form, which the server checks at boot by parsing it. Register MICAFORGE_PUBLIC_URL + /api/github/callback as the App’s callback URL, with “Request user authorization (OAuth) during installation” on, and MICAFORGE_PUBLIC_URL + /api/github/webhook as its webhook URL.

These are separate from MICAFORGE_GITHUB_CLIENT_ID and _SECRET, which belong to the OAuth app behind “Continue with GitHub”; either can be set without the other. With none of the six set, the server makes no call to GitHub for this and refuses every delivery to the webhook.