流媒体技术学习笔记之(二)RTMP和HLS分发服务器nginx.conmf配置文件(解决了,只能播放RTMP流而不能够播放HLS流的原因)

user www www;
worker_processes  1;

error_log  logs/error.log  debug;

#pid        logs/nginx.pid;

events {
    worker_connections  65535;
}

rtmp {
    server {
        listen 1935;

        application live {
                live on;
                record off;
        }

        application live2 {
                live on;
                record off;
        }

       # application hls {  #这一块的注释,不然的话.m3u8流是没办法播放的
       #    live on;
            hls on;
            hls_path /tmp/hls;
        #    hls_cleanup off;
        # }

    }
}

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

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

    access_log  logs/access.log  main;

    sendfile        on;
    keepalive_timeout  65;

    server
        {
        listen       80;
        server_name  localhost;

        location /rtmp/stat {
            rtmp_stat all;
            rtmp_stat_stylesheet rtmpstat.xsl;
        }

        location /rtmpstat.xsl {
        }

        location /rtmp/control {
            rtmp_control all;
        }

        location /hls{
            types {
                application/vnd.apple.mpegurl m3u8;
            }
            root /tmp;
            add_header Cache-Control no-cache;
            add_header Access-Control-Allow-Origin *;
        }

        #控制rtmp模块
        location /control {
            rtmp_control all;
        }
    }

}

参照网址:

rtmp与hls流媒体服务器搭建:ubuntu下Nginx搭建初探与rtmp-module的添加

https://my.oschina.net/joshuashaw/blog/516015

nginx-rtmp-module 指令详解

http://blog.csdn.net/aoshilang2249/article/details/51483814

原文地址:https://www.cnblogs.com/tinywan/p/5915543.html