user root; error_log /dev/stderr info; worker_processes 1; worker_rlimit_nofile 20000; events { use epoll; worker_connections 20000; multi_accept on; } http { include mime.types; default_type application/octet-stream; keepalive_timeout 60; server_tokens off; # HTTP 访问日志定向到标准输出 access_log /dev/stdout; server { listen 80; server_name live.reghao.cn; rewrite ^(.*) https://$host permanent; } server { listen 443 ssl; server_name live.reghao.cn; ssl_certificate /data/ssl/reghao.cn/fullchain.cer; ssl_certificate_key /data/ssl/reghao.cn/reghao.cn.key; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; location /live { flv_live on; #打开 HTTP 播放 FLV 直播流功能 chunked_transfer_encoding on; #支持 'Transfer-Encoding: chunked' 方式回复 add_header 'Access-Control-Allow-Origin' '*'; #添加额外的 HTTP 头 add_header 'Access-Control-Allow-Credentials' 'true'; #添加额外的 HTTP 头 } location /hls { types { application/vnd.apple.mpegurl m3u8; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; video/mp2t ts; } root /tmp; add_header 'Cache-Control' 'no-cache'; } location /dash { root /tmp; add_header 'Cache-Control' 'no-cache'; } #如果需要 JSON 风格的 stat, 不用指定 stat.xsl #但是需要指定一个新的配置项 rtmp_stat_format location /stat { rtmp_stat all; rtmp_stat_format json; } location /control { rtmp_control all; #rtmp 控制模块的配置 } location / { root /var/www; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } } rtmp { # log_format rtmp_log_format '$remote_addr [$time_local] $command "$app" "$name" "$args" - $bytes_received bytes'; # access_log /dev/stdout rtmp_log_format; server { listen 1935; chunk_size 4096; # /rtmp/cam201 application rtmp { live on; gop_cache on; #打开 GOP 缓存,减少首屏等待时间 record all; record_suffix _%Y%m%d_%H%M%S.flv; record_path /data/rtmp; record_max_size 1M; # 录制的单个 flv 文件最大值 record_unique on; #on_publish https://auth.reghao.cn/api/auth/rtmp/on_publish; #on_publish_done https://auth.reghao.cn/api/auth/rtmp/on_publish_done; #on_play https://auth.reghao.cn/api/auth/rtmp/on_play; #on_play_done https://auth.reghao.cn/api/auth/rtmp/on_play_done; #on_record_done https://auth.reghao.cn/api/auth/rtmp/on_record_done; } application vod { live on; gop_cache on; #打开 GOP 缓存,减少首屏等待时间 } application hls { live on; hls on; hls_path /tmp/hls; } application dash { live on; dash on; dash_path /tmp/dash; hls_fragment 10s; } } }