coturn服务器搭建及踩坑
安装coturn
安装之前,先确保使用以下命令将apt-get更新到最新:
sudo apt-get update |
安装coturn:
sudo apt-get install coturn |
请确保使用以下命令在安装软件包后停止该服务, 因为安装完成后它将自动启动:
systemctl stop coturn |
生成证书文件
sudo openssl req -x509 -newkey rsa:2048 -keyout /etc/turn_server_pkey.pem -out /etc/turn_server_cert.pem -days 99999 -nodes |
备份并创建配置文件
安装好coturn后会在/etc
目录下创建turnserver.conf
首先备份:
copy the original turnserver configuration file to a backup in the same directory |
用编辑器编辑turnserver.conf
:
tips:内网地址是使用
ifconfig
后显示的地址,外网地址云服务器公网地址
listening-device=eth0 |
编辑/etc/default/coturn
文件(去掉下面这句前面的#):
TURNSERVER_ENABLED=1 |
开放端口
云服务器端口打开:
1-65535 UDP |
重启coturn:
service coturn restart |
这将启动服务器中的coturn服务。你可以使用以下命令检查服务的状态:
systemctl status coturn |
这里我踩的坑:记得关掉软件防火墙(ufw)!!!!!!!!!!
测试
测试地址:https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/
看到 relay 类型的就说明成功了
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 LP瞎逼逼!
评论