Skip to content

Self-host MiroTalk LK

Self-host MiroTalk LK with one script: the install script running in a terminal

Run MiroTalk LK on your own Ubuntu server: the app, LiveKit and Redis in Docker Compose, with Nginx and a free Let's Encrypt certificate in front. The automated setup does all of it with one script; the manual setup shows every step.

Prefer Caddy, or need TURN over TLS on port 443 for strict corporate networks? See Production deployment.

Requirements

  • A clean server running Ubuntu 22.04 or 24.04 LTS with root access.
  • At least 2 vCPUs, 2 GB RAM and 20 GB disk (x86_64 or arm64). Recording adds ~2-4 vCPUs per concurrent recording, self-hosted captions ~2 vCPUs and 1 GB RAM.
  • Two DNS A records pointing to the server's public IPv4: one for the app and one for LiveKit's signalling (it needs its own domain for wss://):
Record Example Used for
App domain meet.example.com The web app (https://)
LiveKit domain livekit.example.com LiveKit signalling (wss://), set in LIVEKIT_URL

Ports

Port Protocol Open to the internet Description
22 TCP yes SSH
80 TCP yes HTTP: Let's Encrypt challenges, redirect to HTTPS
443 TCP yes HTTPS: the app and LiveKit signalling (through Nginx)
7881 TCP yes WebRTC media over TCP (fallback for networks without UDP)
7882 UDP yes WebRTC media (all calls, multiplexed on one port)
3030 TCP no The app, reached by Nginx on 127.0.0.1
7880 TCP no LiveKit API/WebSocket, reached by Nginx on 127.0.0.1
6379 TCP no Redis, only on the Docker network

Media (audio, video, screen sharing) does not pass through Nginx: browsers connect directly to the server's public IP on 7881/tcp and 7882/udp. If your cloud provider has its own firewall or security group, open those ports there too.

Automated setup

Run as root on the server and, when prompted, enter your app domain, then your LiveKit domain (default livekit.<app domain>), then whether only signed-in hosts may start meetings.

Bash
# Install MiroTalk LK
wget -qO lk-install.sh https://docs.mirotalk.com/scripts/lk/lk-install.sh \
  && chmod +x lk-install.sh \
  && ./lk-install.sh
Bash
# Update MiroTalk LK
wget -qO lk-update.sh https://docs.mirotalk.com/scripts/lk/lk-update.sh \
  && chmod +x lk-update.sh \
  && ./lk-update.sh
Bash
# Uninstall MiroTalk LK
wget -qO lk-uninstall.sh https://docs.mirotalk.com/scripts/lk/lk-uninstall.sh \
  && chmod +x lk-uninstall.sh \
  && ./lk-uninstall.sh

The scripts live in scripts/, so they're versioned with the code, and docs.mirotalk.com serves a copy of the latest ones for the commands above. After installing, they're also on the server, e.g. /root/mirotalk-lk/scripts/lk-update.sh.

What the install script does

  1. Checks the OS, CPU, RAM and disk, finds the server's public IP and verifies that both domains point to it.
  2. Installs Docker Engine with the Compose plugin (from Docker's repository), Git, Nginx and Certbot.
  3. Clones the repository to /root/mirotalk-lk and creates .env from .env.example with production settings:
    • NODE_ENV=production, TRUST_PROXY=loopback, uniquelocal (only the local Nginx is trusted), OG_URL=https://<app domain>
    • LIVEKIT_URL=wss://<LiveKit domain> and LIVEKIT_NODE_IP=<public IP>
    • a newly generated LIVEKIT_API_KEY, LIVEKIT_API_SECRET and SESSION_SECRET
    • with host sign-in (the default), HOST_USERS=admin:<generated password>, so only you can start meetings (guests still join with the invite link)
  4. Writes docker-compose.override.yml, which publishes LiveKit's 7880 on 127.0.0.1 only (Docker's published ports bypass ufw, so it can't rely on the firewall), then builds and starts the containers and waits for /healthz.
  5. Gets one Let's Encrypt certificate for both domains (webroot, renewed automatically by Certbot's timer, which reloads Nginx) and writes the Nginx site /etc/nginx/sites-available/mirotalk-lk.
  6. If ufw is active, allows 80/tcp, 443/tcp, 7881/tcp and 7882/udp.

At the end it prints your URL, the host sign-in and the LiveKit credentials. They are all kept in /root/mirotalk-lk/.env.

Unattended install

Every prompt can be answered with an environment variable instead:

Bash
DOMAIN=meet.example.com LIVEKIT_DOMAIN=livekit.example.com HOST_SIGN_IN=y ./lk-install.sh
Variable Default Description
DOMAIN prompted App domain
LIVEKIT_DOMAIN prompted (livekit.<DOMAIN>) LiveKit signalling domain
HOST_SIGN_IN prompted (y) y: create a host account (HOST_USERS); n: anyone with the URL can start meetings
LETSENCRYPT_EMAIL admin@<DOMAIN> Email for Let's Encrypt expiry notices
SERVER_IP detected The server's public IPv4 (LIVEKIT_NODE_IP)
SKIP_DNS_CHECK false true when the domains don't resolve to the server directly (e.g. behind a CDN)
REPO_URL this repository Git repository to install from (e.g. your fork)
REPO_BRANCH default branch Branch or tag to install
PROJECT_DIR /root/mirotalk-lk Install directory (pass the same to the update and uninstall scripts)

Update and uninstall

lk-update.sh runs git pull, lists settings added to .env.example since your last update, pulls the pinned images, rebuilds the app and restarts what changed. Your .env, docker-compose.override.yml and recordings are kept, and so are the optional services in COMPOSE_PROFILES.

lk-uninstall.sh asks for confirmation, then removes the containers, their volumes and the built images, /root/mirotalk-lk (including .env), the Nginx site and the certificate. Recordings are moved to /root/mirotalk-lk-recordings-<date> unless you choose to delete them. Docker, Nginx and Certbot stay installed.

Manual setup (Nginx)

The same steps as the script, if you'd rather run them yourself or adapt them.

1. Docker

Install Docker Engine with the Compose plugin (2.24 or newer) following Docker's guide for Ubuntu, then check it:

Bash
docker compose version

2. Get the code and configure it

Bash
git clone https://github.com/miroslavpejic85/mirotalk-lk.git
cd mirotalk-lk
cp .env.example .env
chmod 600 .env

# Generate LiveKit keys and a session secret
docker run --rm livekit/livekit-server:v1.13.11 generate-keys
openssl rand -hex 32

Edit .env (see Configuration for everything else):

INI
NODE_ENV=production
TRUST_PROXY=loopback, uniquelocal
LIVEKIT_URL=wss://livekit.example.com
LIVEKIT_API_KEY=<generated key>
LIVEKIT_API_SECRET=<generated secret>
LIVEKIT_NODE_IP=<server public IPv4>
SESSION_SECRET=<openssl rand -hex 32>
OG_URL=https://meet.example.com
# Recommended on public servers: only these hosts can start meetings
HOST_USERS=admin:<a long random password>

Keep LiveKit's API port off the internet (Nginx proxies it), and create the recordings folder:

Bash
cat > docker-compose.override.yml <<'EOF'
services:
    livekit:
        ports: !override
            - '127.0.0.1:7880:7880'
            - '7881:7881'
            - '7882:7882/udp'
EOF

mkdir -p recordings && chmod 777 recordings

3. Start

Bash
docker compose up -d --build

# Both should answer
curl http://127.0.0.1:3030/healthz
curl http://127.0.0.1:7880        # LiveKit answers "OK"

4. Nginx and Let's Encrypt

Bash
apt-get install -y nginx certbot
mkdir -p /var/www/letsencrypt

Create /etc/nginx/sites-available/mirotalk-lk with the HTTP part first (replace the domains):

Nginx Configuration File
server {
    listen 80;
    listen [::]:80;
    server_name meet.example.com livekit.example.com;

    location /.well-known/acme-challenge/ {
        root /var/www/letsencrypt;
    }

    location / {
        return 301 https://$host$request_uri;
    }
}

Enable it and get one certificate for both domains:

Bash
ln -s /etc/nginx/sites-available/mirotalk-lk /etc/nginx/sites-enabled/mirotalk-lk
nginx -t && systemctl reload nginx

certbot certonly --webroot -w /var/www/letsencrypt \
  --cert-name meet.example.com -d meet.example.com -d livekit.example.com \
  --agree-tos -m you@example.com --deploy-hook "systemctl reload nginx"

Then add the HTTPS part to the same file:

Nginx Configuration File
map $http_upgrade $mirotalk_lk_connection_upgrade {
    default upgrade;
    ''      close;
}

# MiroTalk LK app
server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name meet.example.com;

    ssl_certificate /etc/letsencrypt/live/meet.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/meet.example.com/privkey.pem;

    # In-browser recordings are uploaded in 16 MB chunks.
    client_max_body_size 20m;

    # Prometheus metrics (METRICS_ENABLED) are for your monitoring network, not the internet.
    location = /metrics {
        return 404;
    }

    location / {
        proxy_pass http://127.0.0.1:3030;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        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 $mirotalk_lk_connection_upgrade;

        # Large headers/cookies from some single sign-on providers.
        proxy_buffer_size       128k;
        proxy_buffers         8 256k;
        proxy_busy_buffers_size 512k;
    }
}

# LiveKit signalling (WebSocket)
server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name livekit.example.com;

    ssl_certificate /etc/letsencrypt/live/meet.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/meet.example.com/privkey.pem;

    location / {
        proxy_pass http://127.0.0.1:7880;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        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 $mirotalk_lk_connection_upgrade;
        proxy_buffering off;
        proxy_read_timeout 86400s;
        proxy_send_timeout 86400s;
    }
}
Bash
nginx -t && systemctl reload nginx

# Check that renewal works
certbot renew --dry-run --cert-name meet.example.com

Open https://meet.example.com; https://livekit.example.com should answer OK.

5. Firewall

ufw:

Bash
ufw allow 22/tcp
ufw allow 80/tcp
ufw allow 443/tcp
ufw allow 7881/tcp
ufw allow 7882/udp
ufw enable

iptables:

Bash
# Allow established traffic and loopback
iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT

# Keep SSH open first (avoid lockout)
iptables -A INPUT -p tcp --dport 22 -j ACCEPT

# Web and WebRTC media
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -A INPUT -p tcp --dport 7881 -j ACCEPT
iptables -A INPUT -p udp --dport 7882 -j ACCEPT

iptables -P INPUT DROP

# Save rules
apt-get install -y iptables-persistent
netfilter-persistent save

Traffic to ports Docker publishes goes through Docker's own iptables chains (FORWARD), not these INPUT rules: that's why the app (127.0.0.1:3030) and LiveKit's API (127.0.0.1:7880) are only published on the loopback address.

Behind another reverse proxy (Nginx Proxy Manager, Traefik, Caddy...)

Terminate HTTPS at your proxy and forward plain HTTP to the containers:

  • App domain → http://<docker host>:3030. Allow request bodies of at least 20 MB (Nginx Proxy Manager: Advanced → client_max_body_size 20m;).
  • LiveKit domain → http://<docker host>:7880, with WebSockets support enabled.
  • If the proxy runs on another machine, or in a container that can't reach 127.0.0.1 of the host, publish the ports where it can reach them (e.g. APP_BIND_ADDRESS=0.0.0.0) and make sure only the proxy can reach them.
  • In .env: LIVEKIT_URL=wss://<LiveKit domain>, LIVEKIT_NODE_IP=<public IPv4> and TRUST_PROXY set to the proxy's addresses (e.g. loopback, uniquelocal, or its IP).
  • Keep 7881/tcp and 7882/udp open and not proxied: media goes straight to LIVEKIT_NODE_IP.

For Caddy there's a ready-made Caddyfile.example.

Recording and live captions

Both are off by default. Turn them on in .env and list their services in COMPOSE_PROFILES, so docker compose up -d (and lk-update.sh) always starts them:

INI
# Recording with LiveKit Egress
RECORDING_ENABLED=true

# Live captions with self-hosted Whisper
CAPTIONS_ENABLED=true

COMPOSE_PROFILES=recording,captions,whisper
Bash
cd /root/mirotalk-lk
docker compose up -d --build

See Recording (S3 storage, layouts, quality) and Live captions (cloud speech-to-text, models) for the details.

Changing settings

Edit /root/mirotalk-lk/.env, then recreate the containers so they read it:

Bash
cd /root/mirotalk-lk
docker compose up -d

Troubleshooting

  • Logs: cd /root/mirotalk-lk && docker compose logs -f app livekit.
  • "Could not connect" / stuck on joining: check that https://<LiveKit domain> answers OK, that LIVEKIT_URL is wss://<LiveKit domain> and that the Nginx site for it has the WebSocket Upgrade/Connection headers.
  • Black or one-way video, no audio: LIVEKIT_NODE_IP must be the server's public IPv4 (never a Docker or LAN address), and 7881/tcp + 7882/udp must be open in the host firewall and your cloud provider's firewall.
  • Check a network: in the lobby, Test your connection shows whether media goes over UDP, TCP or a TURN relay. Networks that only allow HTTPS need TURN over TLS on port 443: see Restrictive networks. That setup uses its own Layer-4 Caddy on ports 80/443, so stop Nginx first.
  • Certificate: certbot certificates lists it with its expiry date; certbot renew --dry-run tests the renewal.
  • Health: curl http://127.0.0.1:3030/healthz (app) and curl http://127.0.0.1:3030/readyz (app and LiveKit). See Monitoring.