janus 安装部署

本文使用docker进行安装,还没有安装docker和docker-compose的,请自行安装,这里就不介绍了

环境

janus-gateway镜像版本:anyan/janus-gateway:0.10.7
linux版本: Ubuntu 18.04.6 LTS
coturn/coturn 镜像版本: coturn/coturn:latest 镜像ID 8403619f32d4

拉取镜像

docker pull anyan/janus-gateway:0.10.7
docker pull coturn/coturn

获取配置文件

启动coturn

 docker run --net=host -d -p 3478:3478 -p 3478:3478/udp -p 5349:5349 -p 5349:5349/udp -p 40000-40100:40000-40100/udp coturn/coturn

启动janus

docker run -it anyan/janus-gateway:0.10.7 bash

拷贝到指定目录,本示例使用/root/janus作为根目录
使用 docker ps获取到容器的id

$ mkdir -p  /root/janus/etc/janus
$ docker ps | grep janus
794d00df4a2d   canyan/janus-gateway:0.10.7                    "/usr/local/bin/janu…"   41 hours ago   Up 41 hours                                                                                                                                                                                                                                                                                                                                                                     janus_gateway

docker cp 794d00df4a2d:/usr/local/etc/janus/janus.jcfg /root/janus/etc/janus
docker cp 794d00df4a2d:/usr/local/etc/janus/janus.transport.http.jcfg /root/janus/etc/janus
docker cp 794d00df4a2d:/usr/local/etc/janus/janus.websockets.http.jcfg /root/janus/etc/janus
docker cp 794d00df4a2d:/usr/local/share/janus/demos /root/janus

/root/janus/etc/janus/janus.jcfg nat 配置文件内容如下:

nat: {
       stun_server = "10.250.63.74"
       stun_port = 3478
       nice_debug = false
       turn_server = "IP地址"
       turn_port = 3478
       turn_type = "udp"
       turn_user = "admin"
       turn_pwd = "xxx"
       ice_ignore_list = "vmnet"
}

制作证书可以通过openssl进行生成

mkdir -p /root/janus/ssl
cd /root/janus/ssl
openssl rsa -in domain.com.key -text > key.pem
openssl x509 -inform PEM -in domain.com.crt > cert.pem

创建docker-compose.yaml文件

version: '2.1'
services:
  janus-gateway:
    container_name: janus_gateway
    image: 'canyan/janus-gateway:0.10.7'
    command: ["/usr/local/bin/janus", "-F", "/usr/local/etc/janus","--debug-level=7"]
    ports:
      - "9918:9918"
      - "9928:9928"
      - "9938:9938"
      - "8889:8889"
      - "8000:8000"
      - "7088:7088"
      - "7089:7089"
    volumes:
      - "./etc/janus/janus.jcfg:/usr/local/etc/janus/janus.jcfg"
      - "./etc/janus/ssl/cert.csr:/usr/local/etc/ssl/cert.csr"
      - "./etc/janus/ssl/key.pem:/usr/local/etc/ssl/key.pem"
      - "./etc/janus/ssl/cert.pem:/usr/local/etc/ssl/cert.pem"
      - "./etc/janus/janus.transport.http.jcfg:/usr/local/etc/janus/janus.transport.http.jcfg"
      - "./etc/janus/janus.transport.websockets.jcfg:/usr/local/etc/janus/janus.websockets.http.jcfg"
        #- "./etc/janus/janus.eventhandler.sampleevh.jcfg:/usr/local/etc/janus/janus.eventhandler.sampleevh.jcfg"
    restart: always
    network_mode: 'host'

启动服务

cd /root/janus;
docker-compose up -d

安装nginx

apt-get install nginx -y

配置nginx

 cat /etc/nginx/nginx.conf
user  root;
events {
    worker_connections  4096;  ## Default: 1024
}

http {
server {
        listen       80;
        server_name  web_dist;

        location / {
            root   /root/janus/demos;
            index  index.html index.htm;
        }
}

server {
    ssl on;
    listen       443 ssl;
    server_name  localhost;
    root         /root/janus/demos;

    underscores_in_headers on;

    ssl_certificate "/root/janus/ssl/cert.pem";
    ssl_certificate_key "/root/janus/ssl/key.pem";
    location / {
     }

    location /janus/ {
        proxy_pass http://api_server/janus/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Server $host;
    }

    location /ws {
        proxy_pass http://websocket;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
    }
}

# api server
upstream api_server{
  server 0.0.0.0:8088;
}

map $http_upgrade $connection_upgrade {
    default upgrade;
    '' close;
}
upstream websocket {
        server 127.0.0.1:8188;
}

}

需改/root/janus/demos目录下 echotest.js videoroomtest.js文件,文件内容如下

var server = null;
if(window.location.protocol === 'http:')
        server = "http://" + window.location.hostname + "/janus/";
else
        server = "https://" + window.location.hostname + "/janus/";

访问 https://部署IP/videoroomtest.html
sss
点击Start
效果如下
sd
end

代码: https://github.com/meetecho/janus-gateway
docker镜像: https://hub.docker.com/r/canyan/janus-gateway

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值