美文网首页
基于 starRTC 实现(移动端-浏览器)视频通话

基于 starRTC 实现(移动端-浏览器)视频通话

作者: 适量哥 | 来源:发表于2021-10-26 17:57 被阅读0次

docker 部署 starrtc-server

安装 nginx 转发 wss 和配置 https

下载服务端部署文件

git clone https://github.com/starrtc/starrtc-server.git

https 证书配置

openssl 生成

# 复制 https 证书(cert.key、cert.pem)到 web-supported 文件夹
# 替换原来的证书
rm -f starchatroom.key starmsg.key starsrc.key starvdn.key starvoip.key
cp cert.key starchatroom.key && cp test.key starmsg.key && cp test.key starsrc.key && cp test.key starvdn.key && cp test.key starvoip.key
rm -f starchatroom.pem starmsg.pem starsrc.pem starvdn.pem starvoip.pem
cp cert.pem starchatroom.pem && cp test.pem starmsg.pem && cp test.pem starsrc.pem && cp test.pem starvdn.pem && cp test.pem starvoip.pem

新建 nginx 配置文件

worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  localhost;
        location / {
            root   html;
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
    server {
       listen       443 ssl;
       server_name  localhost;
       ssl_certificate      cert.pem;
       ssl_certificate_key  cert.key;
       ssl_session_cache    shared:SSL:1m;
       ssl_session_timeout  5m;
       ssl_ciphers  HIGH:!aNULL:!MD5;
       ssl_prefer_server_ciphers  on;
       location /wss/ {
            proxy_pass http://localhost:19903/;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "Upgrade";
            proxy_set_header X-real-ip $remote_addr;
            proxy_set_header X-Forwarded-For $remote_addr;
        }
    }
}

修改 start.sh

# 注意: 省略了上面的配置,脚本执行过程
# 1、启动 starrtc-server 服务
# 2、启动 nginx 转发 wss,配置 https
# 3、持续输出日志做前台程序,防止 docker 启动完容器直接退出

./supervise.sh start msgServer > msgServer.log
./supervise.sh start chatDBServer
./supervise.sh start groupServer
./supervise.sh start chatRoomServer
./supervise.sh start voipServer > voipServer.log
./supervise.sh start liveSrcServer
./supervise.sh start liveVdnServer
./supervise.sh start liveProxyServer
./supervise.sh start groupPushHttpProxy

ps -aux | grep Server
ps -aux | grep groupPushHttpProxy

systemctl start nginx

tail -f voipServer.log

新建 dockerfile

FROM centos:centos7
RUN yum install -y git nginx
COPY web-supported /opt/web
COPY web-supported/nginx.conf /etc/nginx/nginx.conf
COPY web-supported/test.key /etc/nginx/test.key
COPY web-supported/test.pem /etc/nginx/test.pem 
RUN chmod +777 /opt/web -R
WORKDIR /opt/web
ENTRYPOINT ["/opt/web/start.sh"]

创建镜像文件并运行

docker build -t starrtc-server:v1 .

docker run --name starrtc-server -p 1935:1935 -p 10086-10088:10086-10088 -p 19903-19941:19903-19941 -p 29991-29995:29991-29995 -p 19931:19931/udp -p 10086:10086/udp -p 10088:10088/udp -p 19935:19935/udp -p 19928:19928/udp -p 19941:19941/udp -p 44446:44446/udp -d starrtc-server:v1

相关文章

网友评论

      本文标题:基于 starRTC 实现(移动端-浏览器)视频通话

      本文链接:https://www.haomeiwen.com/subject/qsjyaltx.html