MediaSoup-demo模塊增加nginx

MediaSoup-demo模塊增加nginx

mediasoup-demo app 模塊只能通過 gulp dist,不滿足高併發、高新能要求。這裏添加nginx docker容器,代理app模塊。該項目使用docker容器技術,不會污染宿主機環境。

docker搭建mediasoup參考以下項目:

使用docker 搭建MediaSoup服務

github項目路徑

docker hub 路徑

nginx 配置文件
#nginx.conf
worker_processes  auto;
#error_log  logs/error.log;

events {
    worker_connections  1024;
}

http {
        sendfile off;
        tcp_nopush on;
        directio 512;
        include   /etc/nginx/mime.types; #這裏的配置很重要,缺失導致無法正常加載CSS
        # aio on;
        # HTTP server required to serve the player and HLS fragments
        server {
                listen 9443;
                ssl_certificate     /mediasoup/config/certs/fullchain.pem;
                ssl_certificate_key /mediasoup/config/certs/privkey.pem;
                ssl_session_cache   shared:SSL:10m;
                ssl_session_timeout 10m;
                ssl on;
                location /{
                        root /mediasoup/public;
            try_files $uri /index.html;
            index index.html index.htm index.php;
        }
                location ~* \.(css|gif|ico|jpg|js|png|ttf|woff)$ {
                        root /mediasoup/public;
                }
                location ~* \.(eot|otf|ttf|woff|svg)$ {
            add_header Access-Control-Allow-Origin *;
                        root /mediasoup/public;
         }
        }
}
nginx docker compose 使用

mediasoup-demo-cloud:v2 鏡像已經

version: '3'

services:
    # Frontend
    mediasoupFrontend:
        image: ysf465639310/mediasoup-demo-cloud:v2
        ports:
            - 9443:9443
            - 3000:3000
            
        working_dir: /mediasoup/public
        
        privileged: true
        
        volumes:
            - /etc/localtime:/etc/localtime
            - ../../config/config.js:/mediasoup/config/config.js:rw
            - ../../config/config.js:/mediasoup/server/config.js:rw
            - ../../config/nginx.conf:/etc/nginx/nginx.conf:rw
            - ../nginx:/run/nginx
            
        env_file:
            - ./media.env
        
        command: ["nginx","-c", "/etc/nginx/nginx.conf", "-g", "daemon off;"]
        
        networks:
             cloud_conference:
                ipv4_address: 172.88.0.2
networks:
   cloud_conference:
      ipam:
         config:
         - subnet: 172.88.0.0/16
           #gateway: 172.88.0.1
運行
  1. Step1:

    root@H3CDATA:/opt/CLOUD_MEDIASOUP# cd mediasoup/compose/
    root@H3CDATA:/opt/CLOUD_MEDIASOUP/mediasoup/compose# mv media.env .env
    
  2. Step2

    root@H3CDATA:/opt/CLOUD_MEDIASOUP/mediasoup/compose# docker-compose up -d
    
  3. Step2
    在谷歌瀏覽器中https://host:9443/roomId=1234 訪問,目前火狐瀏覽器 ios手機無法正常使用,原因未知,後期會更新的鏡像,修復這些bug

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章