nginx-plus

时间:2015-09-30 07:25:24

标签: nginx rtmp mpeg-dash

我搜索的足够但无法理清如何在nginx plus中配置mpeg-dash。

rtmp模块支持它我猜,但我不明白它如何配置它并在nginx加服务器中请求它。

当我在nginx.conf中配置rtmp时收到错误

 unknown directive "rtmp" in /etc/nginx/nginx.conf:13

配置

  user  nginx;
  worker_processes  auto;

  error_log  /var/log/nginx/error.log notice;
  pid        /var/run/nginx.pid;


  events {
      worker_connections  1024;
    }

   rtmp {         
     server {

    listen       98;
    server_name  127.0.0.1;          

    application dash {
         live on;
         dash on;
         dash_path /usr/share/nginx/html/dash;
    }
  }
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';

access_log  /var/log/nginx/access.log  main;

sendfile        on;
#tcp_nopush     on;

keepalive_timeout  65;

#gzip  on;

server {
    listen       99;
    server_name  127.0.0.1;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

location / {
    rewrite ^(.*)$ /crossdomain.xml;
}

location = /crossdomain.xml {
    root /var/www/crossdomain;
}


    location /images {
        root   /usr;
    }

    location /flv {
        root   /usr;
        flv;
        mp4_buffer_size       1m;
        mp4_max_buffer_size   5m;
        mp4_limit_rate        on;
        mp4_limit_rate_after  30s;
    }

    location /video {
        root   /usr;
        mp4;
        mp4_buffer_size       1m;
        mp4_max_buffer_size   5m;
        mp4_limit_rate        on;
        mp4_limit_rate_after  30s;
    }

    location /hls {
         root   /usr/share/nginx/html;
         hls;
         hls_fragment            5s;
         hls_buffers             10 10m;
         hls_mp4_buffer_size     1m;
         hls_mp4_max_buffer_size 5m;
         types 
        {
               application/vnd.apple.mpegurl m3u8;
               video/mp2t ts;
        }

  add_header 'Access-Control-Allow-Origin' '*';
  add_header 'Cache-Control' 'no-cache';
    }

    location /dash {
         root /usr/share/nginx/html;
         add_header Cache-Control no-cache;
     }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

include /etc/nginx/conf.d/*.conf;

}

如何在nginx-plus

中启用rtmp

1 个答案:

答案 0 :(得分:0)

rtmp部分必须放在http之外,如下所示:

rtmp {
    server {
    ...
}

http {
    server {
    ...
}

有关完整示例,请参阅自述文件:https://github.com/arut/nginx-rtmp-module