Server Hosting, Auth & Reverse Proxy

Stravia Server runs headless on Linux or Windows, inside containers, or as a declarative NixOS service. By default it binds 127.0.0.1:23471.

Prerequisites

  • Data directory: A writable directory with exclusive instance access (Server enforces .instance.lock).
  • Reverse proxy (for remote access): TLS termination via Nginx, Caddy, or Traefik before exposing /api/v1/* or /v1/* beyond localhost.

Steps

1. Run via Binary, Docker, or NixOS

  • Standalone binary:
    ./stravia-server --data-dir /var/lib/stravia --listen 127.0.0.1:23471
    sh
    Linux Server releases use mimalloc (with C allocator override and MIMALLOC_PURGE_DELAY=0 by default) to reduce steady-state resident memory. When any provider, web provider, or updater uses the default system proxy mode, Server reads standard process proxy environment variables (HTTP_PROXY, HTTPS_PROXY, ALL_PROXY, NO_PROXY) and connects directly if none are set.
  • Docker (ghcr.io/stravia-ai/straviaplatform:latest, runs as nonroot:nonroot UID/GID 65532 and listens on 0.0.0.0:23471 inside the container, HEALTHCHECK hits /healthz):
    docker run -d --name stravia \
      -p 127.0.0.1:23471:23471 \
      -v stravia-data:/data \
      ghcr.io/stravia-ai/straviaplatform:latest
    sh
    If mounting a host directory instead of a named volume, ensure UID/GID 65532 can write to /data.
  • NixOS (services.stravia): Import nixosModules.default from the Stravia flake and set services.stravia.enable = true. The module creates a non-root stravia user/group, binds 127.0.0.1:23471 (firewall untouched), stores state under /var/lib/stravia (0700), and bundles all official vendor plugins via --features bundled-vendors. If overriding services.stravia.configFile, point to a writable runtime file path—never a read-only /nix/store path.

2. Claim initial /setup

On first start without an initialized database, Server prints a one-time setup token and URL to stdout/journal (on NixOS, inspect journalctl -u stravia.service -b—never share logs containing the raw token). Open /setup, select your database backend, and create your administrator username and password.

3. Configure Reverse Proxy, Admin Origins & Trusted Proxies

When serving Stravia behind HTTPS (for example https://stravia.example.com):

  1. Pass --admin-origin https://stravia.example.com (or NixOS services.stravia.adminOrigins) and configure --trusted-proxy (trustedProxies) to match your real reverse proxy IP/CIDR—do not rely on permissive CORS or open firewalls as admin access control.
  2. Proxy both HTTP, Server-Sent Events (/api/v1/observations/events), and WebSocket upgrades (/v1/responses), disabling request/response buffering for streams and allowing bodies up to at least 150m (PROXY_JSON_BODY_LIMIT_BYTES is 140 MiB after decompression).
  3. Set Settings → Artifacts → Client base URL (client_base_url) to your public URL (https://stravia.example.com) so generated image download_url links resolve externally.
location / {
    proxy_pass http://127.0.0.1:23471;
    proxy_http_version 1.1;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_buffering off;
    client_max_body_size 150m;
}
nginx

Verify

  1. Confirm curl -fsS http://127.0.0.1:23471/readyz returns HTTP 200.
  2. Open your public HTTPS URL, log in with your admin cookie session, and check Connect clients → Code shows your public base URL.

Troubleshooting

  • WebSocket /v1/responses or live logs drop every 60s: Increase proxy read/send timeouts and ensure Upgrade / Connection headers plus proxy_buffering off are enabled.
  • Docker container exits with permission error on /data: Fix host mount ownership for UID/GID 65532 (chown -R 65532:65532).
  • Setup token rejected: Restart Server if expired or check that you copied the token from the current boot's startup logs.

Next