Make TURN/STUN port configurable via TURN_PORT env var
UniFi controller uses UDP 3478 for STUN, preventing coturn from binding. Add TURN_PORT variable (default 3478) so users can set TURN_PORT=3479 in .env to avoid the conflict. https://claude.ai/code/session_01Vm6NLaQuzM4VosAotqS1q8
This commit is contained in:
+10
-4
@@ -8,9 +8,9 @@
|
|||||||
# 4. docker exec -it easy-asterisk easy-asterisk
|
# 4. docker exec -it easy-asterisk easy-asterisk
|
||||||
#
|
#
|
||||||
# Port forwarding required on your router:
|
# Port forwarding required on your router:
|
||||||
# 5061/tcp → SIP TLS signaling
|
# 5061/tcp → SIP TLS signaling
|
||||||
# 3478/udp → STUN/TURN (NAT traversal + media relay)
|
# 3478/udp+tcp → STUN/TURN (NAT traversal + media relay)
|
||||||
# 3478/tcp → TURN TCP fallback (for restrictive networks)
|
# (change with TURN_PORT if 3478 is taken)
|
||||||
# 10000-20000/udp → RTP media (or your custom range below)
|
# 10000-20000/udp → RTP media (or your custom range below)
|
||||||
#
|
#
|
||||||
# How it works:
|
# How it works:
|
||||||
@@ -58,7 +58,7 @@ LOCAL_CIDR=
|
|||||||
HAS_VLANS=n
|
HAS_VLANS=n
|
||||||
VLAN_SUBNETS=
|
VLAN_SUBNETS=
|
||||||
|
|
||||||
# ── TURN/STUN Credentials ────────────────────────────────────
|
# ── TURN/STUN Settings ──────────────────────────────────────
|
||||||
# Used by coturn for TURN relay authentication.
|
# Used by coturn for TURN relay authentication.
|
||||||
# If TURN_PASSWORD is empty, a random password is generated on
|
# If TURN_PASSWORD is empty, a random password is generated on
|
||||||
# first startup and saved to /etc/easy-asterisk/config.
|
# first startup and saved to /etc/easy-asterisk/config.
|
||||||
@@ -68,6 +68,12 @@ VLAN_SUBNETS=
|
|||||||
TURN_USERNAME=easyasterisk
|
TURN_USERNAME=easyasterisk
|
||||||
TURN_PASSWORD=
|
TURN_PASSWORD=
|
||||||
|
|
||||||
|
# ── TURN/STUN Port ──────────────────────────────────────────
|
||||||
|
# Default: 3478 (standard STUN/TURN port)
|
||||||
|
# Change if 3478 is already in use (e.g., UniFi controller uses 3478/udp).
|
||||||
|
# Common alternative: 3479
|
||||||
|
TURN_PORT=3478
|
||||||
|
|
||||||
# ── TURN Relay Port Range ─────────────────────────────────────
|
# ── TURN Relay Port Range ─────────────────────────────────────
|
||||||
# Ports coturn uses for media relay. Forward this range on your router.
|
# Ports coturn uses for media relay. Forward this range on your router.
|
||||||
# Default is 100 ports (enough for ~50 simultaneous relayed calls).
|
# Default is 100 ports (enough for ~50 simultaneous relayed calls).
|
||||||
|
|||||||
+1
-1
@@ -79,7 +79,7 @@ EXPOSE 8080/tcp
|
|||||||
EXPOSE 8088/tcp
|
EXPOSE 8088/tcp
|
||||||
EXPOSE 8089/tcp
|
EXPOSE 8089/tcp
|
||||||
|
|
||||||
# STUN (if running coturn in same container)
|
# STUN (if running coturn in same container; default 3478, configurable via TURN_PORT)
|
||||||
EXPOSE 3478/udp
|
EXPOSE 3478/udp
|
||||||
|
|
||||||
# RTP media range (use --network host in production for full range)
|
# RTP media range (use --network host in production for full range)
|
||||||
|
|||||||
+3
-3
@@ -53,7 +53,7 @@ services:
|
|||||||
# ── TURN/STUN Server ──
|
# ── TURN/STUN Server ──
|
||||||
# Points to the coturn service (auto-configured)
|
# Points to the coturn service (auto-configured)
|
||||||
- TURN_ENABLED=y
|
- TURN_ENABLED=y
|
||||||
- TURN_SERVER=${DOMAIN_NAME:?}:3478
|
- TURN_SERVER=${DOMAIN_NAME:?}:${TURN_PORT:-3478}
|
||||||
- TURN_USERNAME=${TURN_USERNAME:-easyasterisk}
|
- TURN_USERNAME=${TURN_USERNAME:-easyasterisk}
|
||||||
- TURN_PASSWORD=${TURN_PASSWORD:-}
|
- TURN_PASSWORD=${TURN_PASSWORD:-}
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ services:
|
|||||||
- DETECT_EXTERNAL_IP=${DETECT_EXTERNAL_IP:-yes}
|
- DETECT_EXTERNAL_IP=${DETECT_EXTERNAL_IP:-yes}
|
||||||
command:
|
command:
|
||||||
- -n
|
- -n
|
||||||
- --listening-port=3478
|
- --listening-port=${TURN_PORT:-3478}
|
||||||
- --fingerprint
|
- --fingerprint
|
||||||
- --lt-cred-mech
|
- --lt-cred-mech
|
||||||
- --user=${TURN_USERNAME:-easyasterisk}:${TURN_PASSWORD:-changeme}
|
- --user=${TURN_USERNAME:-easyasterisk}:${TURN_PASSWORD:-changeme}
|
||||||
@@ -104,7 +104,7 @@ services:
|
|||||||
- --log-file=stdout
|
- --log-file=stdout
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD-SHELL", "turnutils_stunclient 127.0.0.1 >/dev/null 2>&1"]
|
test: ["CMD-SHELL", "turnutils_stunclient -p ${TURN_PORT:-3478} 127.0.0.1 >/dev/null 2>&1"]
|
||||||
interval: 10s
|
interval: 10s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 3
|
retries: 3
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ fi
|
|||||||
mkdir -p "$CONFIG_DIR"
|
mkdir -p "$CONFIG_DIR"
|
||||||
|
|
||||||
# Determine TURN/STUN server address
|
# Determine TURN/STUN server address
|
||||||
turn_server="${TURN_SERVER:-${DOMAIN_NAME:-$local_ip}:3478}"
|
turn_server="${TURN_SERVER:-${DOMAIN_NAME:-$local_ip}:${TURN_PORT:-3478}}"
|
||||||
|
|
||||||
cat > "$CONFIG_FILE" << EOF
|
cat > "$CONFIG_FILE" << EOF
|
||||||
# Easy Asterisk Configuration (Docker) - $(date)
|
# Easy Asterisk Configuration (Docker) - $(date)
|
||||||
|
|||||||
@@ -1599,7 +1599,7 @@ show_firewall_guide() {
|
|||||||
echo " - Protocol: UDP/TCP"
|
echo " - Protocol: UDP/TCP"
|
||||||
echo " - Source: VLAN 10 Net"
|
echo " - Source: VLAN 10 Net"
|
||||||
echo " - Dest: ${CURRENT_PUBLIC_IP:-Server_IP}"
|
echo " - Dest: ${CURRENT_PUBLIC_IP:-Server_IP}"
|
||||||
echo " - Port: 3478"
|
echo " - Port: 3478 (or your TURN_PORT if changed)"
|
||||||
echo ""
|
echo ""
|
||||||
echo "STEP 3: Create Rule 2 (The Relay Range - CRITICAL)"
|
echo "STEP 3: Create Rule 2 (The Relay Range - CRITICAL)"
|
||||||
echo " - Action: Pass (Allow)"
|
echo " - Action: Pass (Allow)"
|
||||||
@@ -1621,7 +1621,7 @@ show_firewall_guide() {
|
|||||||
echo "STEP 2: Create Rule."
|
echo "STEP 2: Create Rule."
|
||||||
echo " - Interface: WAN"
|
echo " - Interface: WAN"
|
||||||
echo " - Protocol: UDP"
|
echo " - Protocol: UDP"
|
||||||
echo " - Dest. Port: 3478 (and 49152-65535)"
|
echo " - Dest. Port: 3478 (or your TURN_PORT) and 49152-65535"
|
||||||
echo " - Redirect IP: ${CURRENT_PUBLIC_IP:-Server_IP}"
|
echo " - Redirect IP: ${CURRENT_PUBLIC_IP:-Server_IP}"
|
||||||
echo ""
|
echo ""
|
||||||
read -p "Press Enter to return..."
|
read -p "Press Enter to return..."
|
||||||
@@ -2748,7 +2748,9 @@ configure_local_client() {
|
|||||||
read -p "TURN Host [${server}]: " th
|
read -p "TURN Host [${server}]: " th
|
||||||
turn_host="${th:-$server}"
|
turn_host="${th:-$server}"
|
||||||
fi
|
fi
|
||||||
turn_config="turn_server turn:${t_user}:${t_pass}@${turn_host}:3478"
|
read -p "TURN Port [3478]: " t_port
|
||||||
|
t_port="${t_port:-3478}"
|
||||||
|
turn_config="turn_server turn:${t_user}:${t_pass}@${turn_host}:${t_port}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update config file for TURN
|
# Update config file for TURN
|
||||||
|
|||||||
Reference in New Issue
Block a user