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