Skip to content

MiroTalk LK production deployment

On a fresh Ubuntu server, Self-hosting does all of this with one script (Docker, Nginx and Let's Encrypt), and has update and uninstall scripts too.

  1. Point two DNS records at your server, e.g. meet.example.com and livekit.example.com.
  2. Generate LiveKit keys:
    Bash
    docker run --rm livekit/livekit-server:v1.13.11 generate-keys
    
  3. Configure .env:
    INI
    NODE_ENV=production
    TRUST_PROXY=true
    LIVEKIT_URL=wss://livekit.example.com
    LIVEKIT_API_KEY=<generated key>
    LIVEKIT_API_SECRET=<generated secret>
    LIVEKIT_NODE_IP=<server public IP>
    
  4. Start the app and LiveKit:
    Bash
    docker compose up -d --build
    
  5. Put HTTPS in front (required for camera/mic/screen access). See Caddyfile.example for an automatic-TLS reverse proxy.
  6. Open firewall ports: 80/tcp, 443/tcp, 7881/tcp (ICE/TCP) and 7882/udp (WebRTC media). Keep 3030, 6379 and 7880 closed to the internet (Caddy proxies them). docker-compose.yml publishes the app on 127.0.0.1 only (APP_BIND_ADDRESS), since ports Docker publishes bypass host firewalls such as ufw.
  7. Optional: set HOST_USERS and/or single sign-on (OIDC_*) so only your hosts can start meetings (see Host sign-in).

To enable recording, see Recording; for live streaming, see Live streaming; for live captions, see Live captions; to notify other systems, see Webhooks.

Production checklist

  • NODE_ENV=production, a generated LIVEKIT_API_SECRET (≥ 32 chars), TRUST_PROXY=true behind the proxy, HTTPS for both domains.
  • The app must only be reachable through the proxy: with TRUST_PROXY=true, a client reaching it directly could set X-Forwarded-For to dodge the per-IP rate limits. To be safe even then, list the proxy's addresses instead, e.g. TRUST_PROXY=loopback, uniquelocal (a proxy on the same machine or Docker network).
  • HOST_USERS or single sign-on (OIDC_*) set on public servers (otherwise anyone with the URL can start meetings and recordings).
  • Image versions are pinned in the compose files; upgrade them deliberately (read the LiveKit release notes first).
  • Fix any warning the app logs at startup (e.g. TRUST_PROXY off, or streaming without STREAMING_ALLOWED_HOSTS).
  • Logs are JSON lines on stdout/stderr (docker compose logs app), one line per API request plus errors; ship them to your log stack if you have one. Each API request has an id (requestId, sent back in the X-Request-Id header, or taken from your proxy's), also in 500 answers, so a user's report can be found in the logs.
  • Privacy: request log lines include the client's IP address (for rate limits and abuse). If your privacy policy needs it, keep logs only briefly, or set LOG_LEVEL=warn to log only failed requests. Error reports never include IPs, cookies or request bodies.
  • GET /healthz is used by the Docker healthcheck; point your uptime monitor at it too. Load balancers should use GET /readyz (see Monitoring).
  • One app instance by default. Rate limits, per-room locks, the waiting room and in-browser recording uploads in progress are kept in memory (and uploads on local disk); this is ideal for one VPS. A restart drops the waiting room (guests ask again) and saves uploads in progress as they are. To run several instances behind a load balancer, set SCALING_MODE=distributed so they share this state in Redis (see Scaling).
  • Host passwords in HOST_USERS can be stored hashed (docker compose run --rm app node src/cli/hash-password.ts, see Host sign-in).
  • Set OG_URL (link previews) and, with single sign-on, OIDC_REDIRECT_URL to your public https:// address, so neither is built from the request's Host header.

Monitoring

Endpoint Use
GET /healthz Liveness: the app process is up. Used by the Docker healthcheck; never depends on LiveKit.
GET /readyz Readiness: 200 when LiveKit's server API (and Redis, when distributed) also answers, 503 otherwise
GET /metrics Prometheus metrics, when METRICS_ENABLED=true. Protect it with METRICS_TOKEN or block it publicly.

The app asks LiveKit at most every 5 seconds (shared by /readyz and /metrics), so frequent checks don't add load. Metrics:

Metric Type Description
mirotalk_livekit_up gauge 1 if the LiveKit server API is reachable, 0 if not
mirotalk_rooms gauge Meetings currently open (omitted while LiveKit is unreachable)
mirotalk_participants gauge Participants across all meetings, as counted by LiveKit
mirotalk_egress_jobs{status} gauge Recording and live streaming jobs by status (starting, active, ending); only with recording or streaming on
mirotalk_live_streams gauge Meetings being streamed live; only with recording or streaming on
process_*, nodejs_* – Standard Node.js process metrics (CPU, memory, event loop lag, GC, handles)

Example Prometheus scrape config (scraping the app directly on the Docker network or host, not through Caddy):

YAML
scrape_configs:
    - job_name: mirotalk-lk
      authorization:
          credentials: <METRICS_TOKEN>
      static_configs:
          - targets: ['app:3030']

LiveKit can expose its own, more detailed Prometheus metrics too (add prometheus_port to livekit.yaml).

Error tracking

Server errors can be sent to any service that accepts the Sentry SDK: Sentry (cloud or self-hosted), Better Stack Errors or GlitchTip. Create a project, copy its DSN and set it:

Bash
SENTRY_DSN=https://<key>@<host>/<project-id>

Only the DSN changes between services. Every error the server logs is reported (LiveKit API failures, failed recordings or webhooks, unexpected 500s and crashes) with its stack trace, tagged with the logger scope and the release (mirotalk-lk@<version>). Before a crash restarts the container, pending reports are flushed for up to 2 seconds.

Reports never include cookies, request bodies, query strings, Authorization headers or client IPs, and outgoing request breadcrumbs keep only the target's origin. Performance tracing is not enabled. With SENTRY_DSN empty, the SDK is not loaded at all.

Analytics

For visitor statistics, point the app at a Umami instance (self-hosted or Umami Cloud) or any tracker that takes the same data-website-id attribute:

Bash
STATS_ENABLED=true
STATS_SRC=https://stats.example.com/script.js
STATS_ID=<website id from Umami>

The script is added to every page and its origin is allowed in the Content-Security-Policy (script-src and connect-src). Query strings and hashes are excluded (data-exclude-search, data-exclude-hash), so room names are never sent to the analytics server.

Shared meeting links show a preview card (title, description and image) in chat apps and social networks, from Open Graph and Twitter Card tags added to the page. They are on by default with the MiroTalk LK texts and public/images/og-image.jpg. To rebrand a self-hosted instance:

Bash
OG_URL=https://meet.example.com
OG_SITE_NAME=Acme Meet
OG_TITLE=Acme Meet
OG_DESCRIPTION=Video meetings for the Acme team.
OG_IMAGE=https://cdn.example.com/acme-og.jpg
OG_IMAGE_ALT=Acme Meet
OG_TWITTER_SITE=@acme

OG_IMAGE can also be a path on this server, e.g. /images/acme-og.jpg (mount it into public/images/).

Crawlers need absolute URLs: without OG_URL they're built from the address the page was requested on (set TRUST_PROXY=true behind a reverse proxy so it's https://). The preview always points to the home page, so room names in shared links are never included. Use an image of about 1200×630 (or 2:1). Set OG_ENABLED=false to leave the tags out.

The name and icon of the installable app come from public/manifest.webmanifest and the PNG icons in public/images/brand (192×192 and 512×512, a 512×512 maskable one with the logo inside the centre 80%, and a 180×180 apple-touch-icon.png for iOS). To rebrand them, mount your own files over those (and change apple-mobile-web-app-title in public/index.html).

Embedding in other apps

By default only this site can show the app in an <iframe>. To put meetings into another web app, allow that app's origin (exact scheme://host[:port], comma-separated, https:// in production):

Bash
EMBED_ALLOWED_ORIGINS=https://app.example.com,https://crm.example.com

The origins are added to the Content-Security-Policy's frame-ancestors. X-Frame-Options is left out because it can't list origins. In the other app, let the iframe use the camera, microphone and screen sharing:

HTML
<iframe
    src="https://meet.example.com/?room=team-sync"
    allow="camera; microphone; display-capture; fullscreen; autoplay; clipboard-write"
    style="width: 100%; height: 720px; border: 0"
></iframe>

Guests can join as usual. Host sign-in (HOST_USERS / OIDC) uses a SameSite=Lax cookie, which browsers don't send inside an iframe on another site, and most sign-in providers can't be shown in an iframe. So meetings that need a signed-in host should be started outside the iframe.

Restrictive networks (TURN/TLS, optional)

WebRTC media normally uses UDP 7882 and falls back to TCP 7881, which covers almost everyone. Networks that only allow HTTPS (some corporate firewalls) need TURN over TLS on port 443. LiveKit always advertises it as turns:<TURN_DOMAIN>:443, so it needs its own domain and has to share port 443 with the app.

docker-compose.turn.yml does this using LiveKit's single-server layout: a Layer-4 Caddy owns ports 80/443, routes each domain (app, LiveKit, TURN) and gets the certificates automatically, while all services use host networking. It replaces Caddyfile.example, so stop any other web server on 80/443 first.

  1. Add a DNS record for the TURN domain (e.g. turn.example.com) pointing at the same server.
  2. In .env set APP_DOMAIN, LIVEKIT_DOMAIN, TURN_DOMAIN (plus the usual LIVEKIT_URL=wss://<LIVEKIT_DOMAIN>, LIVEKIT_NODE_IP, TRUST_PROXY=true).
  3. Start it (add --profile recording for recording or live streaming, --profile captions and --profile whisper for captions):
    Bash
    docker compose -f docker-compose.yml -f docker-compose.turn.yml up -d --build
    
  4. Firewall: open 80/tcp, 443/tcp, 7881/tcp, 7882/udp and 3478/udp (TURN/UDP); keep 3030, 5349, 6379, 7880, 8000, 8080 and 8081 closed.

Requires a Linux host (host networking) and Docker Compose 2.24+. For multi-node deployments see Scaling.

To see what a network allows, open the lobby there and click Test your connection: it shows whether media goes direct over UDP, over TCP or through the TURN relay and, when nothing else gets through, whether TURN is set up and reachable.