#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
#rtmp_auto_push on; #因为Nginx可能开启多个子进程,这个选项表示推流时,媒体流会发布到多个子进程
#rtmp_auto_push_reconnect 1s;
#rtmp_socket_dir /tmp;
rtmp_auto_push on;
rtmp {
server {
listen 1935;
chunk_size 4096;
#ping 30s;
#notify_method get;
application live{
live on;
}
application live_one{
play /tmp/live;
live on;
#record off;
}
application live_http {
play http://localhost/live_one;
}
application live_two{
live on;
#hls on;
#hls_path /tmp/live;
}
application hls{
live on;
hls on;
hls_path /tmp/live;
hls_fragment 10s;
}
}
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
#server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
#下面两个是加上去的,用来配置直播的http访问
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
#注意这里的路径不能错误,直接写绝对路径就可以
root /usr/local/nginx/nginx-rtmp-module/;
}
location / {
root /var/www/html/;
index demo.html index.html index.htm video/index.html;
}
location /hls {
types{
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
add_header Cache-Control no-cache;
add_header Access-Control-Allow-Origin *;
}
#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;
}
location /live {
flv_live on;
add_header Access-Control-Allow-Origin *;
#chunked on; #HTTP协议开启Transfer-Encoding: chunked;方式回复
}
}
server {
listen 80;
server_name localhost;
# rtmp stat
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
#注意这里的路径不能错误,直接写绝对路径就可以
root /usr/local/nginx/nginx-rtmp-module/;
}
location hls {
# Serve HLS fragments
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /tmp;
add_header Cache-Control no-cache;
}
location /dash {
# Serve DASH fragments
root /tmp;
add_header Cache-Control no-cache;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/html;
}
}
}