Skip to content

Commit 1c79290

Browse files
- add guide to documentation and example files to repository to run coturn alongside PairDrop via Docker Compose
- enable TURN over TLS - modified the .gitignore to ignore files with user-data - should fix #105 - partly cherry-picked from #106 Co-authored-by: xundeenergie <[email protected]>
1 parent 750f543 commit 1c79290

File tree

5 files changed

+97
-18
lines changed

5 files changed

+97
-18
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ node_modules
33
fqdn.env
44
/docker/certs
55
qrcode-svg/
6+
turnserver.conf
7+
rtc_config.json
8+
ssl/

docker-compose-coturn.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,28 @@ services:
44
image: "lscr.io/linuxserver/pairdrop:latest"
55
container_name: pairdrop
66
restart: unless-stopped
7+
volumes:
8+
- ./rtc_config.json:/home/node/app/rtc_config.json
79
environment:
810
- PUID=1000 # UID to run the application as
911
- PGID=1000 # GID to run the application as
1012
- WS_FALLBACK=false # Set to true to enable websocket fallback if the peer to peer WebRTC connection is not available to the client.
1113
- RATE_LIMIT=false # Set to true to limit clients to 1000 requests per 5 min.
12-
- RTC_CONFIG=false # Set to the path of a file that specifies the STUN/TURN servers.
14+
- RTC_CONFIG=/home/node/app/rtc_config.json # Set to the path of a file that specifies the STUN/TURN servers.
1315
- DEBUG_MODE=false # Set to true to debug container and peer connections.
1416
- TZ=Etc/UTC # Time Zone
1517
ports:
1618
- "127.0.0.1:3000:3000" # Web UI. Change the port number before the last colon e.g. `127.0.0.1:9000:3000`
1719
coturn_server:
1820
image: "coturn/coturn"
19-
restart: always
20-
network_mode: "host"
21+
restart: unless-stopped
2122
volumes:
2223
- ./turnserver.conf:/etc/coturn/turnserver.conf
23-
#you need to copy turnserver_example.conf to turnserver.conf and specify domain, IP address, user and password
24+
- ./ssl/:/etc/coturn/ssl/
25+
ports:
26+
- "3478:3478"
27+
- "3478:3478/udp"
28+
- "5349:5349"
29+
- "5349:5349/udp"
30+
- "10000-20000:10000-20000/udp"
31+
# see guide at docs/host-your-own.md#coturn-and-pairdrop-via-docker-compose

docs/host-your-own.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Beware that you have to host your own TURN server to enable transfers between di
66

77
Follow [this guide](https://gabrieltanner.org/blog/turn-server/) to either install coturn directly on your system (Step 1)
88
or deploy it via Docker (Step 5).
9+
10+
You can use the `docker-compose-coturn.yml` in this repository. See [Coturn and PairDrop via Docker Compose](#coturn-and-pairdrop-via-docker-compose).
911

1012
Alternatively, use a free, pre-configured TURN server like [OpenRelay](https://www.metered.ca/tools/openrelay/)
1113

@@ -546,6 +548,54 @@ service apache2 reload
546548

547549
<br>
548550

551+
## Coturn and PairDrop via Docker Compose
552+
553+
### Setup container
554+
To run coturn and PairDrop at once by using the `docker-compose-coturn.yml` with TURN over TLS enabled
555+
you need to follow these steps:
556+
557+
1. Generate or retrieve certificates for your `<DOMAIN>` (e.g. letsencrypt / certbot)
558+
2. Create `./ssl` folder: `mkdir ssl`
559+
3. Copy your ssl-certificates and the privkey to `./ssl`
560+
4. Restrict access to `./ssl`: `chown -R nobody:nogroup ./ssl`
561+
5. Create a dh-params file: `openssl dhparam -out ./ssl/dhparams.pem 4096`
562+
6. Copy `rtc_config_example.json` to `rtc_config.json`
563+
7. Copy `turnserver_example.conf` to `turnserver.conf`
564+
8. Change `<DOMAIN>` in both files to the domain where your PairDrop instance is running
565+
9. Change `username` and `password` in `turnserver.conf` and `rtc-config.json`
566+
10. To start the container including coturn run: \
567+
`docker compose -f docker-compose-coturn.yml up -d`
568+
569+
<br>
570+
571+
#### Setup container
572+
To restart the container including coturn run: \
573+
`docker compose -f docker-compose-coturn.yml restart`
574+
575+
<br>
576+
577+
#### Setup container
578+
To stop the container including coturn run: \
579+
`docker compose -f docker-compose-coturn.yml stop`
580+
581+
<br>
582+
583+
### Firewall
584+
To run PairDrop including its own coturn-server you need to punch holes in the firewall. These ports must be opened additionally:
585+
- 3478 tcp/udp
586+
- 5349 tcp/udp
587+
- 10000:20000 tcp/udp
588+
589+
<br>
590+
591+
### Firewall
592+
To run PairDrop including its own coturn-server you need to punch holes in the firewall. These ports must be opened additionally:
593+
- 3478 tcp/udp
594+
- 5349 tcp/udp
595+
- 10000:20000 tcp/udp
596+
597+
<br>
598+
549599
## Local Development
550600

551601
### Install

rtc_config_example.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
"sdpSemantics": "unified-plan",
33
"iceServers": [
44
{
5-
"urls": "stun:stun.l.google.com:19302"
5+
"urls": "stun:<DOMAIN>:3478"
66
},
77
{
8-
"urls": "turn:example.com:3478",
8+
"urls": "turns:<DOMAIN>:5349",
99
"username": "username",
1010
"credential": "password"
1111
}

turnserver_example.conf

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,51 @@ server-name=pairdrop
66
listening-ip=0.0.0.0
77

88
# External IP-Address of the TURN server
9-
external-ip=<IP_ADDRESS>
9+
# only needed, if coturn is behind a NAT
10+
# external-ip=<IP_ADDRESS>
1011

11-
# Main listening port
12+
# Main listening port for STUN and TURN
1213
listening-port=3478
1314

15+
# Main listening port for TURN over TLS (TURNS)
16+
# Use port 443 to bypass some firewalls
17+
tls-listening-port=5349
18+
1419
# Further ports that are open for communication
1520
min-port=10000
1621
max-port=20000
1722

1823
# Use fingerprint in TURN message
1924
fingerprint
2025

21-
# Log file path
22-
log-file=/var/log/turnserver.log
23-
2426
# Enable verbose logging
25-
verbose
27+
# verbose
28+
29+
# Log file path
30+
# - is logging to STDOUT, so it's visible in docker-compose logs
31+
log-file=-
2632

2733
# Specify the user for the TURN authentification
28-
user=user:password
34+
user=username:password
2935

3036
# Enable long-term credential mechanism
3137
lt-cred-mech
3238

3339
# SSL certificates
34-
cert=/etc/letsencrypt/live/<DOMAIN>/cert.pem
35-
pkey=/etc/letsencrypt/live/<DOMAIN>/privkey.pem
36-
37-
# 443 for TURN over TLS, which can bypass firewalls
38-
tls-listening-port=443
40+
cert=/etc/coturn/ssl/cert.crt
41+
pkey=/etc/coturn/ssl/pkey.pem
42+
dh-file=/etc/coturn/ssl/dhparam.pem
43+
44+
# For security-reasons disable old ssl and tls-protocols
45+
# and other recommended options: see https://github.com/coturn/coturn/blob/master/examples/etc/turnserver.conf
46+
no-sslv3
47+
no-tlsv1
48+
no-tlsv1_1
49+
no-tlsv1_2
50+
no-rfc5780
51+
no-stun-backward-compatibility
52+
response-origin-only-with-rfc5780
53+
no-cli
54+
no-multicast-peers
55+
no-software-attribute
56+
check-origin-consistency

0 commit comments

Comments
 (0)