#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 { server { listen 1935; #监听的端口 chunk_size 4000; application live {#rtmp推流请求路径 (切记路径错了会推不上流) live on; #开启实时 hls on; #开启hls hls_path /usr/local/src/nginx/html/cctv; #rtmp推流请求路径,文件存放路径 hls_fragment 2s; #每个TS文件包含5秒的视频内容 hls_playlist_length 10s; allow play all; } } } http { include 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 logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location /cctv { #添加视频流存放地址。 types { application/vnd.apple.mpegurl m3u8; video/mp2t ts; } #访问权限开启,否则访问这个地址会报403 autoindex on; alias /usr/local/src/nginx/html/cctv/;#视频流存放地址,与上面的hls_path相对应,这里root和alias的区别可自行百度 expires -1; add_header Cache-Control no-cache; #防止跨域问题 add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; } location / { root html; index index.html index.htm; } #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; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} server { listen 88; # 拉流使用的端口,使用默认端口80时,拉流时可不指定 server_name localhost; location /stat { rtmp_stat all; rtmp_stat_stylesheet stat.xsl; } # 查看状态的部分,下部分介绍,不需要可去掉 location /stat.xsl { root /usr/local/nginx-rtmp-module/; } } }