Project

General

Profile

Install Mediasoup API on Ubuntu Bionic » History » Version 8

Olivier Bitsch, 04/15/2021 07:04 AM

1 1 Olivier Bitsch
# Install Mediasoup API on Ubuntu Bionic
2
3
This guide will provide the correct way to deploy mediasoup-api on public server.
4
5 2 Olivier Bitsch
### Install repository
6 1 Olivier Bitsch
7
~~~
8
echo "deb [trusted=yes] https://projects.iabsis.com/repository/mediasoup-api/debian bionic main" \
9
  > /etc/apt/sources.list.d/iabsis.list
10
11
cat > /etc/apt/auth.conf << EOF
12
machine projects.iabsis.com
13
login iabsis-apt
14
password <password>
15
EOF
16 6 Olivier Bitsch
17 7 Olivier Bitsch
chmod 600 /etc/apt/auth.conf
18 1 Olivier Bitsch
~~~
19
20 2 Olivier Bitsch
###  Install package
21 1 Olivier Bitsch
22
~~~
23 8 Olivier Bitsch
apt update && apt install mediasoup-api nginx
24 2 Olivier Bitsch
~~~
25
26
### Configure Mediasoup
27
28 5 Olivier Bitsch
    nano /etc/mediasoup-api/mediasoup-api.conf
29
30 2 Olivier Bitsch
~~~
31
## Define random key here
32
JWT_SECRET=<change secret>
33
34
## Configure credentials used to consume mediasoup API
35
API_USER=<define login>
36
API_SECRET=<define password>
37
38
## Define here the public IP server
39
PUBLIC_IP=<define local server IP>
40
41
## If server is behind nat, you might need to advertise 
42
# the real public IP by commenting out this line.
43
;ANNOUNCED_IP=1.2.3.4
44
45
## You will need to open UDP port in the follow range, you
46
# can adjust the range if required.
47
RTC_MIN_PORT=40000
48
RTC_MAX_PORT=49000
49
50
## If this server is behind a reverse proxy, you might need to trust it
51
TRUST_PROXY=127.0.0.1
52
53
## The best practice is to use reverse proxy, but if you want
54
# this API to serve directly HTTPS, you might need to configure the
55
# following lines
56
HTTP_ONLY=true
57
LISTEN=3480
58
;CERT=/etc/mediasoup-api/sample.localhost.cert.pem
59
;KEY=/etc/mediasoup-api/sample.localhost.key.pem
60
LISTEN_REDIRECT=3481
61 1 Olivier Bitsch
~~~
62 5 Olivier Bitsch
63
    nano /usr/share/mediasoup-api/config/config.js
64
65
66 3 Olivier Bitsch
67
### Enable mediasoup at boot
68
69
~~~
70
systemctl enable mediasoup-api
71 4 Olivier Bitsch
systemctl start mediasoup-api
72
~~~
73
74
### Configure Nginx
75
76
~~~
77
cat > /etc/nginx/sites-enabled/mediasoup-api.conf << EOF
78
map $http_upgrade $connection_upgrade {
79
    default upgrade;
80
    ''      close;
81
}
82
83
server {
84
    server_name <domain>;
85
86
    location / {
87
        proxy_set_header Host $host;
88
        proxy_pass https://localhost:3480;
89
        proxy_set_header X-Forwarded-For $remote_addr;
90
91
        proxy_http_version 1.1;
92
        proxy_set_header Upgrade $http_upgrade;
93
        proxy_set_header Connection $connection_upgrade;
94
95
        proxy_set_header X-Forwarded-Proto $scheme;
96
        proxy_set_header X-Forwarded-Port $server_port;
97
98
        proxy_connect_timeout 120m;
99
        proxy_send_timeout 120m;
100
        proxy_read_timeout 120m;
101
    }
102
103
    listen 80;
104
105
}
106
EOF
107 3 Olivier Bitsch
~~~