RaiCentral

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

bash
cp .env.production.example .env
chmod 600 .env
openssl rand -hex 32   # generate a different value for each secret
VariableValue
POSTGRES_PASSWORDGenerated
JWT_SECRET_KEYGenerated, at least 32 characters
EVIDENCE_ENCRYPTION_KEYGenerated. Keep a copy: stored encrypted data needs it
APP_PUBLIC_URLPublic console URL
CORS_ALLOWED_ORIGINSThe console origin, never *
NEXT_PUBLIC_API_BASE_URLPublic API URL without a trailing slash. Compiled into the console
COMPOSE_FILEPreset 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

bash
docker compose up -d --build
docker compose exec rai-gateway rai-gateway admin create --role admin

Invite 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 Host and sets X-Forwarded-Proto and X-Forwarded-For
  • does not buffer API responses
  • forwards both /.well-known/oauth-* paths to the API unchanged

One host name, API under /api

.env
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=lax
The trailing slash removes the prefix
location /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 *.