Project

General

Profile

Actions

Install Mediasoup API on Ubuntu Bionic » History » Revision 5

« Previous | Revision 5/9 (diff) | Next »
Olivier Bitsch, 04/15/2021 06:59 AM


Install Mediasoup API on Ubuntu Bionic

This guide will provide the correct way to deploy mediasoup-api on public server.

Install repository

echo "deb [trusted=yes] https://projects.iabsis.com/repository/mediasoup-api/debian bionic main" \
  > /etc/apt/sources.list.d/iabsis.list

cat > /etc/apt/auth.conf << EOF
machine projects.iabsis.com
login iabsis-apt
password <password>
EOF

Install package

apt install mediasoup-api nginx

Configure Mediasoup

nano /etc/mediasoup-api/mediasoup-api.conf
## Define random key here
JWT_SECRET=<change secret>

## Configure credentials used to consume mediasoup API
API_USER=<define login>
API_SECRET=<define password>

## Define here the public IP server
PUBLIC_IP=<define local server IP>

## If server is behind nat, you might need to advertise 
# the real public IP by commenting out this line.
;ANNOUNCED_IP=1.2.3.4

## You will need to open UDP port in the follow range, you
# can adjust the range if required.
RTC_MIN_PORT=40000
RTC_MAX_PORT=49000

## If this server is behind a reverse proxy, you might need to trust it
TRUST_PROXY=127.0.0.1

## The best practice is to use reverse proxy, but if you want
# this API to serve directly HTTPS, you might need to configure the
# following lines
HTTP_ONLY=true
LISTEN=3480
;CERT=/etc/mediasoup-api/sample.localhost.cert.pem
;KEY=/etc/mediasoup-api/sample.localhost.key.pem
LISTEN_REDIRECT=3481
nano /usr/share/mediasoup-api/config/config.js

Enable mediasoup at boot

systemctl enable mediasoup-api
systemctl start mediasoup-api

Configure Nginx

cat > /etc/nginx/sites-enabled/mediasoup-api.conf << EOF
map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

server {
    server_name <domain>;

    location / {
        proxy_set_header Host $host;
        proxy_pass https://localhost:3480;
        proxy_set_header X-Forwarded-For $remote_addr;

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;

        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Port $server_port;

        proxy_connect_timeout 120m;
        proxy_send_timeout 120m;
        proxy_read_timeout 120m;
    }

    listen 80;

}
EOF

Updated by Olivier Bitsch over 3 years ago · 5 revisions