Install HCW@Home on UbuntuDebian » History » Version 1
Olivier Bitsch, 08/22/2023 03:04 PM
1 | 1 | Olivier Bitsch | # Install HCW@Home on Ubuntu/Debian |
---|---|---|---|
2 | |||
3 | ### Installation |
||
4 | |||
5 | HCW@Home is provided as source code only but also as Redhat/Rocky or Ubuntu/Debian package now available on our public repositories. If you need this access, please contact us. This setup install all packages on one same server while it's possible to distribute all components across various servers, required to support thousand of users in same time. |
||
6 | |||
7 | #### Requirements |
||
8 | |||
9 | Those are requirements of few users all on one server. |
||
10 | |||
11 | #### Ubuntu/Debian |
||
12 | |||
13 | The first step is to ensure your server is in your prefered timezone. Despitate HCW@Home tries to display times with your current timezone (e.g. by using your browser timezone), there are case where time is send based on server timezone (e.g an SMS with scheduled consultation). To reconfigure timezone on your local server, use the following command. |
||
14 | |||
15 | ~~~ |
||
16 | dpkg-reconfigure tzdata |
||
17 | ~~~ |
||
18 | |||
19 | HCW@Home relies on third party repository as there is no mongo or nodejs into official repositories. |
||
20 | |||
21 | ~~~ |
||
22 | apt -y install curl gnupg ca-certificates lsb-release |
||
23 | |||
24 | # NodeJS Repository |
||
25 | NAME=nodejs |
||
26 | VERSION=12 |
||
27 | KEY_URL="https://deb.nodesource.com/gpgkey/nodesource.gpg.key" |
||
28 | APT_URL="deb https://deb.nodesource.com/node_${VERSION}.x $(lsb_release -sc) main" |
||
29 | PACKAGE=nodejs |
||
30 | |||
31 | curl -s ${KEY_URL} | apt-key add - |
||
32 | echo ${APT_URL} > /etc/apt/sources.list.d/${NAME}.list |
||
33 | apt update |
||
34 | apt install ${PACKAGE} |
||
35 | |||
36 | # MongoDB Repository |
||
37 | NAME=mongodb |
||
38 | VERSION=4.4 |
||
39 | KEY_URL="https://www.mongodb.org/static/pgp/server-${VERSION}.asc" |
||
40 | APT_URL="deb http://repo.mongodb.org/apt/debian $(lsb_release -sc)/mongodb-org/${VERSION} main" |
||
41 | PACKAGE=mongodb-org |
||
42 | |||
43 | curl -s ${KEY_URL} | apt-key add - |
||
44 | echo ${APT_URL} > /etc/apt/sources.list.d/${NAME}.list |
||
45 | apt update |
||
46 | apt install ${PACKAGE} |
||
47 | ~~~ |
||
48 | |||
49 | Now install HCW@Home repositories official repositories. |
||
50 | |||
51 | ~~~ |
||
52 | cat > /tmp/test << EOF |
||
53 | deb [trusted=yes] https://projects.iabsis.com/repository/hcw-backend/debian focal main |
||
54 | deb [trusted=yes] https://projects.iabsis.com/repository/mediasoup-api/debian bionic main |
||
55 | deb [trusted=yes] https://projects.iabsis.com/repository/hcw-patient/debian focal main |
||
56 | deb [trusted=yes] https://projects.iabsis.com/repository/hcw-doctor/debian focal main |
||
57 | EOF |
||
58 | ~~~ |
||
59 | |||
60 | All packages can now be installed in one command. |
||
61 | |||
62 | ~~~ |
||
63 | apt install \ |
||
64 | hcw-athome-patient \ |
||
65 | hcw-athome-backend \ |
||
66 | hcw-athome-caregiver \ |
||
67 | nginx \ |
||
68 | python3-certbot-nginx \ |
||
69 | mongodb-server \ |
||
70 | postfix \ |
||
71 | clamav-daemon \ |
||
72 | redis-server \ |
||
73 | mediasoup-api \ |
||
74 | coturn |
||
75 | ~~~ |
||
76 | |||
77 | By default, HCW@Home doesn't install Nginx configuration. You can use the ready configuration from doc folder. |
||
78 | Once in place, you have to adjust them, especially the domain part that must fit with your environment. |
||
79 | |||
80 | ~~~ |
||
81 | cp /usr/share/doc/hcw-athome-backend/nginx-samples/hcw-athome-patient.conf /etc/nginx/sites-enabled/ |
||
82 | cp /usr/share/doc/hcw-athome-backend/nginx-samples/hcw-athome-doctor.conf /etc/nginx/sites-enabled/ |
||
83 | rm /etc/nginx/sites-enabled/default |
||
84 | ~~~ |
||
85 | |||
86 | We strongly suggest to add rate limits, avoiding anybody to flood the server with requests. A basic of 10 requests per second should fit any requests. |
||
87 | |||
88 | ~~~ |
||
89 | echo "limit_req_zone $http_x_forwarded_for zone=mylimit:10m rate=10r/s;" >> /etc/nginx/sites-enabled/hcw-athome-doctor.conf |
||
90 | echo "proxy_headers_hash_bucket_size 128;" >> /etc/nginx/sites-enabled/hcw-athome-doctor.conf |
||
91 | ~~~ |
||
92 | |||
93 | Mediasoup-API is not provided with Nginx configuration sample. You can create the file `/etc/nginx/sites-enabled/mediasoup.conf` and put the following content. Again, don't forgot to adjust the <domain> part with your custom sub domain name. |
||
94 | |||
95 | ~~~ |
||
96 | map $http_upgrade $connection_upgrade { |
||
97 | default upgrade; |
||
98 | '' close; |
||
99 | } |
||
100 | |||
101 | server { |
||
102 | server_name <domain>; |
||
103 | |||
104 | location / { |
||
105 | proxy_set_header Host $host; |
||
106 | proxy_pass https://localhost:3443; |
||
107 | proxy_set_header X-Forwarded-For $remote_addr; |
||
108 | |||
109 | proxy_http_version 1.1; |
||
110 | proxy_set_header Upgrade $http_upgrade; |
||
111 | proxy_set_header Connection $connection_upgrade; |
||
112 | |||
113 | proxy_set_header X-Forwarded-Proto $scheme; |
||
114 | proxy_set_header X-Forwarded-Port $server_port; |
||
115 | |||
116 | proxy_connect_timeout 120m; |
||
117 | proxy_send_timeout 120m; |
||
118 | proxy_read_timeout 120m; |
||
119 | } |
||
120 | |||
121 | listen 80; |
||
122 | } |
||
123 | ~~~ |
||
124 | |||
125 | Once nginx configuration is ready, you can choose to put a reverse proxy in front of this installation, or install certificates with the following command. Install the certificate for the three domains required by HCW@Home. |
||
126 | |||
127 | ~~~ |
||
128 | certbot --nginx |
||
129 | ~~~ |
||
130 | |||
131 | Replace some vars into `/etc/mediasoup-api/mediasoup-api.conf` to have is working properly behind a reverse proxy. |
||
132 | |||
133 | ~~~ |
||
134 | sed -i 's|HTTP_ONLY=false|HTTP_ONLY=true|g' /etc/mediasoup-api/mediasoup-api.conf |
||
135 | sed -i 's|;LISTEN=3443|LISTEN=3443|g' /etc/mediasoup-api/mediasoup-api.conf |
||
136 | ~~~ |
||
137 | |||
138 | Service user must be added to clamav group, so HCW@Home can you the socket file for making file check. |
||
139 | Also adjust the path to this socket file into HCW@Home configuration. |
||
140 | |||
141 | ~~~ |
||
142 | adduser hcwhome clamav |
||
143 | sed -i 's|/var/run/clamd.scan/clamd.sock|/var/run/clamav/clamd.ctl|g' /etc/hcw-athome/hcw-athome.conf |
||
144 | ~~~ |
||
145 | |||
146 | Coturn configuration is required to allow relay. It's recommended to install several coturn servers, but having coturn on same server than HCW@Home is also supported. It's also recommended to have two public IP addresses to get full coturn capabilities. |
||
147 | |||
148 | The first step is to define pair of credential in addition of a realm of your choice. |
||
149 | |||
150 | ~~~ |
||
151 | turnadmin -k -u <user> -r <domain> -p <pass> |
||
152 | ~~~ |
||
153 | |||
154 | This returns a chain that will be put into `/etc/turnserver.conf` configuration file. Make other adjustements according to the following configuration. |
||
155 | |||
156 | ~~~ |
||
157 | # Enable only if your server is behind a NAT. |
||
158 | external-ip=<you machine ip> |
||
159 | # Adjust only if you want to use another port. |
||
160 | listening-port=3478 |
||
161 | fingerprint |
||
162 | lt-cred-mech |
||
163 | max-port=65535 |
||
164 | min-port=49152 |
||
165 | |||
166 | # This should be the same than the one used during turnadmin command. |
||
167 | realm=<domain> |
||
168 | |||
169 | # user=<user>:<chain return by turnadmin> by example |
||
170 | user=myuser:0xab... |
||
171 | ~~~ |
||
172 | |||
173 | Now adjust the config file of Mediasoup. Adjustment is currently done under `/usr/share/mediasoup-api/config/config.js`. Be careful to keep a copy of this file somewhere as it might be overrided during mediasoup-api package upgrade. |
||
174 | |||
175 | ~~~ |
||
176 | // backupTurnServers : [ |
||
177 | // { |
||
178 | // urls : [ |
||
179 | // 'turn:<domain>:3478?transport=udp' |
||
180 | // ], |
||
181 | // username : '<user>', |
||
182 | // credential : '<pass>' |
||
183 | // } |
||
184 | // ], |
||
185 | ~~~ |
||
186 | |||
187 | Now declare the mediasoup servers into mongo. You can add as many as you want, HCW@Home will pickup one randomly one, check if there is no more session than expected the use it. |
||
188 | |||
189 | ~~~ |
||
190 | mongo |
||
191 | use hcw-athome |
||
192 | db.mediasoupserver.insertOne({url:'https://<mediasoup domain>', username:'<user>', password:'<pass>',maxNumberOfSessions:10}) |
||
193 | ~~~ |
||
194 | |||
195 | Now declare the translation organisations, if none just use |
||
196 | |||
197 | ~~~ |
||
198 | mongo |
||
199 | use hcw-at-home |
||
200 | db.translationorganization.insertOne({ "name" : "Default", "mainEmail" : "", "languages" : [ "fr" ], "canRefuse" : true, "createdAt" : 1645793656770, "updatedAt" : 1645793656770, "reportEmail" : "" }) |
||
201 | |||
202 | We now can enable and start all services. |
||
203 | |||
204 | ~~~ |
||
205 | systemctl restart coturn |
||
206 | systemctl enable --now mediasoup-api |
||
207 | systemctl enable --now clamav-daemon |
||
208 | systemctl enable --now mongodb |
||
209 | systemctl enable --now hcw-athome |
||
210 | ~~~ |