Skip to content

Commit 34b79ff

Browse files
committed
Based on PR163 from netaskd
jitsi#163 Fix prosody configuration Fix web configuration Fix name : turn => coturn Update README.md
2 parents baed605 + 14d717c commit 34b79ff

File tree

11 files changed

+155
-3
lines changed

11 files changed

+155
-3
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FORCE_REBUILD ?= 0
22
JITSI_RELEASE ?= stable
33
JITSI_BUILD ?= latest
44
JITSI_REPO ?= jitsi
5-
JITSI_SERVICES ?= base base-java web prosody jicofo jvb jigasi etherpad jibri
5+
JITSI_SERVICES ?= base base-java web prosody jicofo jvb jigasi etherpad jibri coturn
66

77
BUILD_ARGS := --build-arg JITSI_REPO=$(JITSI_REPO)
88
ifeq ($(FORCE_REBUILD), 1)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ The installation manual is available [here](https://jitsi.github.io/handbook/doc
1515
## TODO
1616

1717
* Support container replicas (where applicable).
18-
* TURN server.
18+
1919

coturn.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
version: '3'
2+
3+
services:
4+
# coturn TURN server project
5+
turn:
6+
image: jitsi/coturn
7+
restart: always
8+
volumes:
9+
- ${CONFIG}/turn:/config
10+
ports:
11+
- '${TURN_PORT}:${TURN_PORT}/tcp'
12+
- '${TURN_PORT}:${TURN_PORT}/udp'
13+
- '${TURN_RTP_MIN}-${TURN_RTP_MAX}:${TURN_RTP_MIN}-${TURN_RTP_MAX}/udp'
14+
- '${TURN_ADMIN_PORT}:${TURN_ADMIN_PORT}/tcp'
15+
environment:
16+
- DOCKER_HOST_ADDRESS
17+
- TURN_SECRET
18+
- TURN_REALM
19+
- TURN_HOST
20+
- TURN_PORT
21+
- TURN_TRANSPORT
22+
- TURN_RTP_MIN
23+
- TURN_RTP_MAX
24+
- TURN_ADMIN_ENABLE
25+
- TURN_ADMIN_USER
26+
- TURN_ADMIN_SECRET
27+
- TURN_ADMIN_PORT
28+
networks:
29+
meet.jitsi:
30+

coturn/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
ARG VERSION
2+
FROM instrumentisto/coturn:${VERSION:-latest}
3+
4+
RUN apk add --no-cache openssl
5+
6+
ADD ./rootfs/defaults/docker-entrypoint.sh /docker-entrypoint.sh
7+
8+
ENTRYPOINT ["/docker-entrypoint.sh"]
9+
10+
VOLUME ["/config"]
11+
12+
EXPOSE 5349 8443 10000:11000/udp
13+

coturn/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
build:
2+
docker build $(BUILD_ARGS) -t $(JITSI_REPO)/coturn .
3+
4+
.PHONY: build
5+
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/ash
2+
3+
# make certs if not exist
4+
if [[ ! -f /config/cert.crt || ! -f /config/cert.key ]]; then
5+
openssl req -newkey rsa:2048 -nodes -keyout /config/cert.key -x509 -days 3650 -out /config/cert.crt -subj "/C=US/ST=NY/L=NY/O=IT/CN=${TURN_HOST}"
6+
fi
7+
8+
# use non empty TURN_PUBLIC_IP variable, othervise set it dynamically.
9+
[ -z "${TURN_PUBLIC_IP}" ] && export TURN_PUBLIC_IP=$(curl -4ks https://icanhazip.com)
10+
[ -z "${TURN_PUBLIC_IP}" ] && echo "ERROR: variable TURN_PUBLIC_IP is not set and can not be set dynamically!" && kill 1
11+
12+
# set coturn web-admin access
13+
if [[ "${TURN_ADMIN_ENABLE}" == "1" || "${TURN_ADMIN_ENABLE}" == "true" ]]; then
14+
turnadmin -A -u ${TURN_ADMIN_USER:-admin} -p ${TURN_ADMIN_SECRET:-changeme}
15+
export TURN_ADMIN_OPTIONS="--web-admin --web-admin-ip=$(hostname -i) --web-admin-port=${TURN_ADMIN_PORT:-8443}"
16+
fi
17+
18+
# run coturn server with API auth method enabled.
19+
turnserver -n ${TURN_ADMIN_OPTIONS} \
20+
--verbose \
21+
--prod \
22+
--no-tlsv1 \
23+
--no-tlsv1_1 \
24+
--log-file=stdout \
25+
--listening-port=${TURN_PORT:-5349} \
26+
--tls-listening-port=${TURN_PORT:-5349} \
27+
--alt-listening-port=${TURN_PORT:-5349} \
28+
--alt-tls-listening-port=${TURN_PORT:-5349} \
29+
--cert=/config/cert.crt \
30+
--pkey=/config/cert.key \
31+
--min-port=${TURN_RTP_MIN:-10000} \
32+
--max-port=${TURN_RTP_MAX:-11000} \
33+
--no-stun \
34+
--use-auth-secret \
35+
--static-auth-secret=${TURN_SECRET:-keepthissecret} \
36+
--no-multicast-peers \
37+
--realm=${TURN_REALM:-realm} \
38+
--listening-ip=$(hostname -i) \
39+
--external-ip=${TURN_PUBLIC_IP} \
40+
--cli-password=NotReallyCliUs3d \
41+
--no-cli
42+

docker-compose.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ services:
3939
- JIBRI_RECORDER_USER
4040
- JIBRI_RECORDER_PASSWORD
4141
- ENABLE_RECORDING
42+
- TURN_ENABLE
4243
networks:
4344
meet.jitsi:
4445
aliases:
@@ -104,6 +105,11 @@ services:
104105
- JWT_TOKEN_AUTH_MODULE
105106
- LOG_LEVEL
106107
- TZ
108+
- TURN_ENABLE
109+
- TURN_SECRET
110+
- TURN_HOST
111+
- TURN_PORT
112+
- TURN_TRANSPORT
107113
networks:
108114
meet.jitsi:
109115
aliases:

env.example

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,3 +327,43 @@ JIBRI_LOGS_DIR=/config/logs
327327
# Container restart policy
328328
# Defaults to unless-stopped
329329
RESTART_POLICY=unless-stopped
330+
# Use TURN for P2P and JVB (bridge mode) connections
331+
#TURN_ENABLE=0
332+
333+
# Realm to be used for the users with long-term credentials mechanism or with TURN REST API
334+
#TURN_REALM=realm
335+
336+
# Secret for connect to TURN server
337+
#TURN_SECRET=keepthissecret
338+
339+
# Annonce FQDN/IP address of the turn server via XMPP server (XEP-0215).
340+
# If empty or not set, variable DOCKER_HOST_ADDRESS will be used by default.
341+
#TURN_HOST=turn.example.com
342+
343+
# Public IP address for an instance of turn server.
344+
# If empty or not set, will be detected and set dynamically when a container start.
345+
#TURN_PUBLIC_IP=144.144.144.144
346+
347+
# TLS/TCP/UDP turn port for connection
348+
#TURN_PORT=5349
349+
350+
# Transport for stun/turn connection. Can be tcp or udp.
351+
#TURN_TRANSPORT=tcp
352+
353+
# RTP start port for turn/turns connections
354+
#TURN_RTP_MIN=16000
355+
356+
# RTP end port for turn/turns connections
357+
#TURN_RTP_MAX=17000
358+
359+
# Enable admin web access. If enabled, please set variables below.
360+
#TURN_ADMIN_ENABLE=0
361+
362+
# Username for admin panel
363+
#TURN_ADMIN_USER=admin
364+
365+
# Password for admin panel
366+
#TURN_ADMIN_SECRET=changeme
367+
368+
# HTTP(s) port for acess to admin panel
369+
#TURN_ADMIN_PORT=8443

prosody/Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,18 @@ RUN \
4747
&& apt-cleanup \
4848
&& rm -rf /tmp/pkg /var/cache/apt
4949

50-
RUN patch -d /usr/lib/prosody/modules/muc -p0 < /prosody-plugins/muc_owner_allow_kick.patch
5150

5251
COPY rootfs/ /
5352

5453
COPY --from=builder /usr/local/lib/lua /usr/local/lib/lua
5554
COPY --from=builder /usr/local/share/lua /usr/local/share/lua
5655

56+
ADD https://raw.githubusercontent.com/netaskd/mod_turncredentials/master/mod_turncredentials.lua /prosody-plugins/mod_turncredentials.lua
57+
58+
RUN \
59+
sed -i s/hook/hook_global/g /prosody-plugins/mod_auth_token.lua \
60+
&& patch -d /usr/lib/prosody/modules/muc -p0 < /prosody-plugins/muc_owner_allow_kick.patch
61+
5762
EXPOSE 5222 5347 5280
5863

5964
VOLUME ["/config", "/prosody-plugins-custom"]

prosody/rootfs/defaults/conf.d/jitsi-meet.cfg.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,16 @@ VirtualHost "{{ .Env.XMPP_DOMAIN }}"
5252
"ping";
5353
"speakerstats";
5454
"conference_duration";
55+
{{ if .Env.TURN_ENABLE | default "0" | toBool }}
56+
"turncredentials";
57+
{{end}}
5558
{{ if .Env.XMPP_MODULES }}
5659
"{{ join "\";\n\"" (splitList "," .Env.XMPP_MODULES) }}";
5760
{{ end }}
5861
{{ if and $ENABLE_AUTH (eq $AUTH_TYPE "ldap") }}
5962
"auth_cyrus";
6063
{{end}}
64+
6165
}
6266

6367
speakerstats_component = "speakerstats.{{ .Env.XMPP_DOMAIN }}"

0 commit comments

Comments
 (0)