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