openssl 1.0 对应libevent2.0.* , openssl1.1对应libevent2.1.*
如下安装libevent-2.0.21, libevent-2.1*版本类似
wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
tar zxvf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable && ./configure
make && make install
2. 编译安装coturn
git clone https://github.com/coturn/coturn
cd coturn
./configure #
make install
which turnserver #安装目录在/usr/local/bin/turnserver
3. 配置
cd /usr/local/etc/
cp turnserver.conf.default turnserver.conf
openssl req -x509 -newkey rsa:2048 -keyout /usr/local/etc/turn_server/turn_server_pkey.pem -out /usr/local/etc/turn_server/turn_server_cert.pem -days 99999 -nodes
code\vi /usr/local/etc/turnserver.conf
关键配置文件
relay-device=eth0 #与前ifconfig查到的网卡名称一致
#内网IP
listening-ip=10.254.1.86
listening-port=3478
tls-listening-port=5349
relay-ip=10.254.1.86
#47.107.110.xxx 阿里云 #公网IP
external-ip=10.254.1.86
relay-threads=50
realm=zzh.com
lt-cred-mech
fingerprint
cli-password=123456
cert=/usr/local/etc/turn_server/turn_server_cert.pem
pkey=/usr/local/etc/turn_server/turn_server_pkey.pem
pidfile=/var/tmp/turnserver.pid
#rtp端口范围
min-port=49152
max-port=65535
user=zzh:123456 #用户名密码,创建IceServer时用,不填写也可以,需要在启动的时候传入
其他配置仔细阅读turnserver.conf
4. 启动
turnserver -help #查看启动命令
turnserver -u zzh:123456
turnserver -o -u zzh:123456 #daemon方式启动
5. 测试
webrtc官方测试地址
webrtc国内某厂商
1). ICE servers
STUN or TURN URI:
TURN username:
TURN password: