Przeglądaj źródła

jvb: make colibri websocket endpoints dynamic for multiple jvbs

Paul Tiedtke 4 lat temu
rodzic
commit
b277926332

+ 5 - 0
jvb/rootfs/defaults/sip-communicator.properties

@@ -4,6 +4,10 @@ org.jitsi.videobridge.TCP_HARVESTER_PORT={{ .Env.JVB_TCP_PORT }}
 {{ if .Env.JVB_STUN_SERVERS }}
 org.ice4j.ice.harvest.STUN_MAPPING_HARVESTER_ADDRESSES={{ .Env.JVB_STUN_SERVERS }}
 {{ end }}
+{{ if .Env.DOCKER_HOST_ADDRESS }}
+org.ice4j.ice.harvest.NAT_HARVESTER_LOCAL_ADDRESS={{ .Env.LOCAL_ADDRESS }}
+org.ice4j.ice.harvest.NAT_HARVESTER_PUBLIC_ADDRESS={{ .Env.DOCKER_HOST_ADDRESS }}
+{{ end }}
 {{ $JVB_TCP_PORT := .Env.JVB_TCP_PORT | default "4443" }}
 {{ $JVB_TCP_MAPPED_PORT := .Env.JVB_TCP_MAPPED_PORT | default $JVB_TCP_PORT }}
 {{ if not (eq $JVB_TCP_PORT $JVB_TCP_MAPPED_PORT) }}
@@ -28,5 +32,6 @@ org.jitsi.videobridge.rest.COLIBRI_WS_DISABLE=false
 org.jitsi.videobridge.rest.jetty.port=9090
 org.jitsi.videobridge.rest.COLIBRI_WS_DOMAIN={{ $WS_DOMAIN }}
 org.jitsi.videobridge.rest.COLIBRI_WS_TLS=true
+org.jitsi.videobridge.rest.COLIBRI_WS_SERVER_ID={{ .Env.LOCAL_ADDRESS }}
 
 org.jitsi.videobridge.rest.private.jetty.host=0.0.0.0

+ 2 - 0
jvb/rootfs/etc/cont-init.d/10-config

@@ -1,5 +1,7 @@
 #!/usr/bin/with-contenv bash
 
+export LOCAL_ADDRESS=$(ip addr show dev "$(ip route|awk '/^default/ { print $5 }')" | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
+
 if [[ -z $JVB_AUTH_PASSWORD ]]; then
     echo 'FATAL ERROR: JVB auth password must be set'
     exit 1

+ 2 - 11
jvb/rootfs/etc/services.d/jvb/run

@@ -1,16 +1,7 @@
 #!/usr/bin/with-contenv bash
 
-JAVA_SYS_PROPS="-Dnet.java.sip.communicator.SC_HOME_DIR_LOCATION=/ -Dnet.java.sip.communicator.SC_HOME_DIR_NAME=config -Djava.util.logging.config.file=/config/logging.properties"
-
-if [[ ! -z "$DOCKER_HOST_ADDRESS" ]]; then
-    LOCAL_ADDRESS=$(ip route get "$DOCKER_HOST_ADDRESS" | head -n1 | cut -d " " -f7)
-    JAVA_SYS_PROPS="$JAVA_SYS_PROPS -Dorg.ice4j.ice.harvest.NAT_HARVESTER_LOCAL_ADDRESS=$LOCAL_ADDRESS -Dorg.ice4j.ice.harvest.NAT_HARVESTER_PUBLIC_ADDRESS=$DOCKER_HOST_ADDRESS"
-fi
+export JAVA_SYS_PROPS="-Dnet.java.sip.communicator.SC_HOME_DIR_LOCATION=/ -Dnet.java.sip.communicator.SC_HOME_DIR_NAME=config -Djava.util.logging.config.file=/config/logging.properties"
 
 DAEMON=/usr/share/jitsi-videobridge/jvb.sh
-DEFAULT_DAEMON_OPTS="none"
-
-DAEMON_OPTS=${JVB_ENABLE_APIS:=$DEFAULT_DAEMON_OPTS}
-
-exec s6-setuidgid jvb /bin/bash -c "JAVA_SYS_PROPS=\"$JAVA_SYS_PROPS\" exec $DAEMON --apis=${DAEMON_OPTS}"
 
+exec s6-setuidgid jvb /bin/bash -c "exec $DAEMON --apis=${JVB_ENABLE_APIS:="none"}"

+ 2 - 2
web/rootfs/defaults/meet.conf

@@ -35,8 +35,8 @@ location ~ ^/(libs|css|static|images|fonts|lang|sounds|connection_optimization|.
 }
 
 # colibri (JVB) websockets
-location ~ ^/colibri-ws/default-id/(.*) {
-    proxy_pass http://jvb.meet.jitsi:9090/colibri-ws/default-id/$1$is_args$args;
+location ~ ^/colibri-ws/([a-zA-Z0-9-\.]+)/(.*) {
+    proxy_pass http://$1:9090/colibri-ws/$1/$2$is_args$args;
     proxy_http_version 1.1;
     proxy_set_header Upgrade $http_upgrade;
     proxy_set_header Connection "upgrade";