Install LiveKit JWT Service
- Navigate to the
/optdirectory:
cd /opt
- Clone the repository:
git clone https://github.com/element-hq/lk-jwt-service.git
cd lk-jwt-service
- Build the executable:
go build -o lk-jwt-service .
/usr/local/go/bin/go build -o lk-jwt-service .
- Install the LiveKit CLI tool:
curl -sSL https://get.livekit.io/ | bash
Install and Configure JWT Service
- Create the file
/etc/systemd/system/lk-jwt-service.servicewith the following content:
[Unit]
Description=LiveKit JWT Service
After=network.target
Requires=livekit-server.service
[Service]
Restart=always
WorkingDirectory=/opt/lk-jwt-service
Environment="LIVEKIT_URL=wss://rtc.domain.com/"
Environment="LIVEKIT_KEY=xxx"
Environment="LIVEKIT_SECRET=xxx"
Environment="LIVEKIT_JWT_PORT=8080"
ExecStart=/opt/lk-jwt-service/lk-jwt-service
[Install]
WantedBy=multi-user.target
- Ensure the executable is in the correct directory:
cp lk-jwt-service /opt/lk-jwt-service/
Install and Configure LiveKit Server
- Create the file
/etc/systemd/system/livekit-server.servicewith the following content:
[Unit]
Description=LiveKit Server Container
After=network.target
[Service]
LimitNOFILE=500000
Restart=always
WorkingDirectory=/opt/livekit
ExecStart=livekit-server --config /etc/livekit/livekit.yaml
[Install]
WantedBy=multi-user.target
- Create the directory
/opt/livekitand copy the LiveKit server binary into it:
mkdir -p /opt/livekit
cp livekit-server /opt/livekit/
- Create the configuration file
/etc/livekit/livekit.yamlwith the following content:
port: 7880
bind_addresses:
- ""
rtc:
tcp_port: 7881
port_range_start: 50000
port_range_end: 50200
use_external_ip: true
ips:
includes:
- 162.55.131.56/26
- 192.168.100.39/32
enable_loopback_candidate: false
turn:
enabled: false
domain: rtc-turn.domain.com
tls_port: 5349
udp_port: 3478
external_tls: true
keys:
xxx: xxx
Enable and Start Systemd Services
- Reload the Systemd daemon configuration:
systemctl daemon-reload
- Enable and start the services:
systemctl enable --now lk-jwt-service.service livekit-server.service
Configure NGINX as a Reverse Proxy
- Open your NGINX configuration file and add the following sections:
location ^~ /livekit/jwt/ {
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;
# JWT Service running at port 8080
proxy_pass http://localhost:8080/;
}
location ^~ /livekit/sfu/ {
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_send_timeout 120;
proxy_read_timeout 120;
proxy_buffering off;
proxy_set_header Accept-Encoding gzip;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# LiveKit SFU websocket connection running at port 7880
proxy_pass http://localhost:7880/;
}
- Test the NGINX configuration:
nginx -t
- Reload the NGINX configuration:
systemctl reload nginx
Verification
- Ensure the services are running:
systemctl status lk-jwt-service.service livekit-server.service
- Test the endpoints:
- JWT Service:
http://<your-domain>/livekit/jwt/ - LiveKit SFU:
http://<your-domain>/livekit/sfu/
- JWT Service:
You must log in or register to comment.

