Docs / Self-hosting
Production deployment
Secrets, the production override, the first administrator and the reverse proxy.
Backups, an identity provider, monitoring and your own security review are required before any production claim.
1. Create the environment file
cp .env.production.example .env
chmod 600 .env
openssl rand -hex 32 # generate a different value for each secret| Variable | Value |
|---|---|
POSTGRES_PASSWORD | Generated |
JWT_SECRET_KEY | Generated, at least 32 characters |
EVIDENCE_ENCRYPTION_KEY | Generated. Keep a copy: stored encrypted data needs it |
APP_PUBLIC_URL | Public console URL |
CORS_ALLOWED_ORIGINS | The console origin, never * |
NEXT_PUBLIC_API_BASE_URL | Public API URL without a trailing slash. Compiled into the console |
COMPOSE_FILE | Preset to docker-compose.yml:docker-compose.prod.yml |
The production override forces ENVIRONMENT=production, disables the bootstrap administrator and shared admin tokens, requires secure cookies and sets the MCP adapter to production mode. The API refuses to start with insecure settings; read docker compose logs rai-gateway if it exits.
If you add the events worker file, append it to COMPOSE_FILE.
2. Start and create the first administrator
docker compose up -d --build
docker compose exec rai-gateway rai-gateway admin create --role adminInvite everyone else from Team & roles in the console. There is no public registration.
3. Put a TLS reverse proxy in front
Containers speak plain HTTP on 127.0.0.1. The repository includes a complete Nginx example at deploy/nginx/raicentral.conf.example. Any proxy works if it:
- strips the API path prefix, if you use one
- preserves
Hostand setsX-Forwarded-ProtoandX-Forwarded-For - does not buffer API responses
- forwards both
/.well-known/oauth-*paths to the API unchanged
One host name, API under /api
APP_PUBLIC_URL=https://rai.example.com
CORS_ALLOWED_ORIGINS=https://rai.example.com
NEXT_PUBLIC_API_BASE_URL=https://rai.example.com/api
AUTH_SET_COOKIES=true
AUTH_COOKIE_SECURE=true
AUTH_COOKIE_SAMESITE=laxlocation /api/ {
proxy_pass http://127.0.0.1:8001/;
}Separate domains
Set NEXT_PUBLIC_API_BASE_URL=https://api.example.com and give that host its own server block proxying / to 127.0.0.1:8001.
Changing NEXT_PUBLIC_API_BASE_URL requires docker compose up -d --build. Never put a secret in a NEXT_PUBLIC_* variable.
Client addresses
Forwarded headers are trusted only from FORWARDED_ALLOW_IPS. Set it to the Compose network gateway address so rate limits and session records see real client addresses. Avoid *.