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