如何为 webRTC 配置 Nginx 的 coturn?

How to config coturn on Nginx for webRTC?

我正在制作一个在 wifi 上运行良好的 WebRTC 应用程序。但是当我通过 4G 在 phone 上打开应用程序时,webRTC Livestream 不会启动。制作 iceConnectionState 似乎出了点问题。

对于 Iceserver,我使用以下设置在我的 Nginx 服务器上使用 coturn 创建了一个 turn 服务器:

listening-port=3478
tls-listening-port=5349

listening-ip=my-public-ip
relay-ip=my-public-ip
external-ip=my-public-ip


fingerprint
user=Dominique:GS7Yq_jK
lt-cred-mech
server-name=domain.com
realm=domain.com
log-file=/var/log/turnserver/turnserver.log
simple-log
external-ip=my-public-ip

total-quota=100
stale-nonce=600

# Authentication method
use-auth-secret
static-auth-secret=33515e71ba1d0a96e77083f7e4215d99afe36204b6f382e1715fbb9314ae61d0

cert=/etc/letsencrypt/live/domain.com/fullchain.pem
pkey=/etc/letsencrypt/live/domain.com/privkey.pem

在我的 nginx.conf 我添加了以下块

stream {
        server {
                listen 3478 udp;
                proxy_pass domain.com:3478;
        }

        server {
                listen 5349 udp;
                proxy_pass domain.com:5349;
        }
}

当我通过这个测试我的 Turn 服务器时 testing site

我通过这些设置得到了这个结果

 urls: 'turn:domain.com:3478',
  username: 'Dominique',
  credential: 'GS7Yq_jK'

但我的回合服务器似乎不工作 有没有人可以帮助我?我想让 WebRTC 在 4G 上工作

感谢您的帮助!

Gr,多米尼克

我找到了这个问题的解决方案 :) 我添加了 /etc/nginx/conf.d/load-balancer.conf 然后 turn 服务器工作了