You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 22, 2023. It is now read-only.
This document covers how to setup a TURN server for BigBlueButton to allow users behind restrictive firewalls to connect.
11
11
12
-
# Setup a TURN server
12
+
You can also use [bbb-install.sh](https://github.com/bigbluebutton/bbb-install#install-a-turn-server) to automate the steps in this document.
13
13
14
-
** This section is being updated for steps to install on Ubuntu 20.04. If you want to setup a TURN server, please use [bbb-install.sh](https://github.com/bigbluebutton/bbb-install#install-a-turn-server). **
14
+
# Setup a TURN server
15
15
16
16
BigBlueButton normally requires a wide range of UDP ports to be available for WebRTC communication. In some network restricted sites or development environments, such as those behind NAT or a firewall that restricts outgoing UDP connections, users may be unable to make outgoing UDP connections to your BigBlueButton server.
17
17
@@ -44,7 +44,7 @@ Note: coturn will not automatically start until configuration is applied (see be
44
44
45
45
## Required DNS Entry
46
46
47
-
You need to setup a fully qualified domain name that resolves to the external IP address of your turn server. You'll used this domain name to generate a TLS certificate using Let's Encrypt (next section).
47
+
You need to setup a fully qualified domain name that resolves to the external IP address of your turn server. You'll use this domain name to generate a TLS certificate using Let's Encrypt (next section).
48
48
49
49
## Required Ports
50
50
@@ -66,41 +66,57 @@ $ sudo apt-get update
66
66
$ sudo apt-get install certbot
67
67
```
68
68
69
-
You can then run a `certbot` command like the following to generate the certificate, replacing `turn.example.com` with the domain name of your TURN server:
69
+
You can then run a `certbot` command like the following to generate the certificate, replacing `<turn.example.com>` with the domain name of your TURN server:
Current versions of the certbot command set up automatic renewal by default. To ensure that the certificates are readable by `coturn`, which runs as the `turnserver` user, add the following renewal-hook to Let's Encrypt. First, create the directory `/etc/letsencrypt/renewal-hooks/deploy`.
Next, create the file `/etc/letsencrypt/renewal-hooks/deploy/coturn` with the following contents. Replace <turn.example.com> with the hostname of your TURN server.
Current versions of the certbot command set up automatic renewal by default. Note that when certbot renews the certificate, it will restart coturn so coturn will start to use the updated certificate files. This will interrupt any ongoing TURN connections. You may wish to change the schedule of certbot renewals or disable automatic renewal if this is a concern.
`coturn` configuration is stored in the file `/etc/turnserver.conf`. There are a lot of options available, all documented in comments in that file. We include a sample configuration below with comments indicating the recommended settings, with some notes in locations where customization is required.
103
+
`coturn` configuration is stored in the file `/etc/turnserver.conf`. There are a lot of options available, all documented in comments in the default configuration file. We include a sample configuration below with the recommended settings (refer to the default configuration file for more information on the settings)..
82
104
83
-
You can repace the contents`/etc/turnserver.conf`with this file and make two changes:
105
+
Use the file below for`/etc/turnserver.conf` and make the following changes:
84
106
85
-
* Replace `turn.example.com` with the hostname of your TURN server, and
86
-
* Replace `<random value>` to a random value for a shared secret (instructions for generating a new secret are in a comment in the file).
107
+
* Replace `<turn.example.com>` with the hostname of your TURN server, and
108
+
* Replace `<example.com>` with the realm of your TURN server, and
109
+
* Replace `<secret_value>` to a random value for a shared secret (you can generate one by running `openssl rand -hex 16`)
110
+
* Replace `<IP>` with the external IP of your TURN server
87
111
88
-
Attention: The `turnserver` process will run as the `turnserver` user, which usually doesn't have access to the certificates/keys in `/etc/letsencrypt/live`. It is recommended that you either create a `ssl-cert` user group, add the `turnserver` user to it and adjust the permissions for `/etc/letsencrypt/live` such that the group can read it or, alternatively, copy the certificates/keys to a safe location (that `turnserver` has access to) after each certificate renewal.
112
+
This configuration file assumes your TURN server is not behind NAT and has a public IP address.
89
113
90
114
```ini
91
-
# Example coturn configuration for BigBlueButton
92
-
93
-
# These are the two network ports used by the TURN server which the client
94
-
# may connect to. We enable the standard unencrypted port 3478 for STUN,
95
-
# as well as port 443 for TURN over TLS, which can bypass firewalls.
96
115
listening-port=3478
97
116
tls-listening-port=443
98
117
99
-
# If the server has multiple IP addresses, you may wish to limit which
100
-
# addresses coturn is using. Do that by setting this option (it can be
101
-
# specified multiple times). The default is to listen on all addresses.
102
-
# You do not normally need to set this option.
103
-
#listening-ip=172.17.19.101
118
+
listening_ip=$IP
119
+
relay_ip=$IP
104
120
105
121
# If the server is behind NAT, you need to specify the external IP address.
106
122
# If there is only one external address, specify it like this:
@@ -111,97 +127,96 @@ tls-listening-port=443
111
127
#external-ip=172.17.19.131/10.0.0.11
112
128
#external-ip=172.17.18.132/10.0.0.12
113
129
114
-
# Fingerprints in TURN messages are required for WebRTC
115
-
fingerprint
130
+
min-port=32769
131
+
max-port=65535
132
+
verbose
116
133
117
-
# The long-term credential mechanism is required for WebRTC
134
+
fingerprint
118
135
lt-cred-mech
119
-
120
-
# Configure coturn to use the "TURN REST API" method for validating time-
121
-
# limited credentials. BigBlueButton will generate credentials in this
122
-
# format. Note that the static-auth-secret value specified here must match
123
-
# the configuration in BigBlueButton's turn-stun-servers.xml
124
-
# You can generate a new random value by running the command:
125
-
# openssl rand -hex 16
126
136
use-auth-secret
127
-
static-auth-secret=<random value>
128
-
129
-
# If the realm value is unspecified, it defaults to the TURN server hostname.
130
-
# You probably want to configure it to a domain name that you control to
131
-
# improve log output. There is no functional impact.
132
-
realm=example.com
133
-
134
-
# Configure TLS support.
135
-
# Adjust these paths to match the locations of your certificate files
# Lower and upper bounds of the UDP relay endpoints:
158
-
# (default values are 49152 and 65535)
159
-
#
160
-
min-port=32768
161
-
max-port=65535
159
+
To increase the file handle limit for the TURN server and to give it the ability to bind to port 443, add the following systemd override file. First, create the directory.
If the TURN server is used by many users concurrently, it might hit the open file-handles limit. Therefore it is recommended to increase this limit by adding `ulimit -n 49152` in `/etc/init.d/coturn` or editing the systemd service specification using `sudo systemctl edit --full coturn` and then adding `LimitNOFILE=49152`. Once this change is applied, restart the coturn service.
165
+
and then then create `/etc/systemd/system/coturn.service.d/override.conf` with the following contents
To rotate the logs for `coturn`, install the following configuration file to `/etc/logrotate.d/coturn`
169
179
170
180
```
171
-
/var/log/coturn.log
181
+
/var/log/turnserver/*.log
172
182
{
173
-
rotate 30
174
-
daily
175
-
missingok
176
-
notifempty
177
-
delaycompress
178
-
compress
179
-
postrotate
180
-
systemctl kill -sHUP coturn.service
181
-
endscript
183
+
rotate 7
184
+
daily
185
+
missingok
186
+
notifempty
187
+
compress
188
+
postrotate
189
+
/bin/systemctl kill -s HUP coturn.service
190
+
endscript
182
191
}
183
192
```
184
193
185
-
## Enabling the coturn service
194
+
And create the associated log directory
186
195
187
-
The ubuntu package for `coturn` requires that you edit a file to enable startup. Edit the file `/etc/default/coturn` and ensure the following line is uncommented:
With the above steps completed, restart the TURN server
194
204
195
205
```bash
196
-
$ systemctl start coturn
206
+
$ sudo /etc/letsencrypt/renewal-hooks/deploy/coturn # Initial copy of certificates
207
+
$ sudo systemctl daemon-reload # Ensure the override file is loaded
208
+
$ sudo systemctl restart coturn # Restart
197
209
```
198
210
199
-
## Configure BigBlueButton to use the coturn server
211
+
Ensure that the `coturn` has binded to port 443 with `netstat -antp | grep 443`. Also restart your TURN server and ensure that `coturn` is running (and binding to port 443 after restart).
212
+
213
+
214
+
# Configure BigBlueButton to use your TURN server
200
215
201
216
You must configure bbb-web so that it will provide the list of turn servers to the web browser. Edit the file `/usr/share/bbb-web/WEB-INF/classes/spring/turn-stun-servers.xml` using the contents below and make edits:
202
217
203
-
* replace both instances of `turn.example.com` with the hostname of the TURN server, and
204
-
* replace `<random value>` with the secret you configured in `turnserver.conf`.
218
+
* replace both instances of `<turn.example.com>` with the hostname of the TURN server, and
219
+
* replace `<secret_value>` with the secret you configured in `turnserver.conf`.
205
220
206
221
```xml
207
222
<?xml version="1.0" encoding="UTF-8"?>
@@ -211,19 +226,19 @@ You must configure bbb-web so that it will provide the list of turn servers to t
If you get an error, check that `coturn` is running on the TURN server using `systemctl status coturn.service`. Check the logs by doing `tail -f /var/log/coturn.log`. You can get verbose logs by adding `verbose` to `/etc/turnserver.conf` and restarting the TURN server `systemctl restart coturn.service`
306
+
If you get an error, check that `coturn` is running on the TURN server using `systemctl status coturn.service`. Check the logs by doing `tail -f /var/log/turnserver/coturn.log`. You can get verbose logs by adding `verbose` to `/etc/turnserver.conf` and restarting the TURN server `systemctl restart coturn.service`
292
307
293
308
294
-
You can test your TURN server using the [trickle ICE](https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/) page. This gives you a log of the relay candidates as they are returned from ICE gathering. To test using this page, you need to generate some test credentials. Run the following BASH script and substitute `<host>` with the hostname of your TURN server and `<password>` with the password for your TURN server.
309
+
You can test your TURN server using the [trickle ICE](https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/) page. This gives you a log of the relay candidates as they are returned from ICE gathering. To test using this page, you need to generate some test credentials. Run the following BASH script and substitute `<turn.example.com>` with the hostname of your TURN server and `<secret_value>` with the password for your TURN server.
295
310
296
311
```bash
297
312
#!/bin/bash
298
313
299
-
HOST=<host>
300
-
SECRET=<password>
314
+
HOST=<turn.example.com>
315
+
SECRET=<secret_value>
301
316
302
317
time=$(date +%s)
303
318
expiry=8400
@@ -313,6 +328,6 @@ echo
313
328
314
329
```
315
330
316
-
Enter the values into URI, username, and password into the trickle ICE page and click 'Gather candidates'. You should see a list of relay candidates. If you don't, again check that your TURN server is running and tail the logs TURN server logs via `tail -f /var/log/coturn.log` or `journalctl -f -u coturn.service`.
331
+
Enter the values into URI, username, and password into the trickle ICE page and click 'Gather candidates'. You should see a list of relay candidates. If you don't, again check that your TURN server is running and tail the logs TURN server logs via `tail -f /var/log/turnserver/coturn.log` or `journalctl -f -u coturn.service`.
317
332
318
333
You can get verbose logs by adding `verbose` to `/etc/turnserver.conf` and then restarting the TURN server `systemctl restart coturn.service`, and try testing again from FireFox or the above Tricke ICE page.
0 commit comments