nginx配置m3u8

nginx配置m3u8只需要配置一个location就可以了,不过在访问时路径时有点区别,播放路径为
http://localhost/video/a.m3u8(文件在/usr/local/nginx/html/video/a.m3u8,video目录有ffmpeg生成的a.m3u8和ts文件)
用root配置路径为/usr/local/nginx/html 作用是把/video拼接在/usr/local/nginx/html下去找资源,下面的配置就会拼接成(/usr/local/nginx/html/video)去这个目录下找a.m3u8
用alias配置为/usr/local/nginx/html/video/ ,alias等于是给目录起了一个别名,必须以 / 结束,下面的配置就是直接去(/usr/local/nginx/html/video/)这个目录找资源
root

location /video {
   	 types{
   		 application/vnd.apple.mpegurl m3u8;
   		 video/mp2t ts;
   	 }
     root /home/local/nginx/html;
     add_header Cache-Control no-cache;
   	 add_header Access-Control-Allow-Origin *;
 }

alias

location /video {
   	 types{
   		 application/vnd.apple.mpegurl m3u8;
   		 video/mp2t ts;
   	 }
     alias /home/local/video;
     add_header Cache-Control no-cache;
   	 add_header Access-Control-Allow-Origin *;
 }

你可能感兴趣的:(nginx,linux,centos)