# HG changeset patch # User Yaroslav Zhuravlev # Date 1395827502 -14400 # Node ID 8cb0c634ff97a30f1565b8b9ef0ef849ff4b62f0 # Parent 15f78372b1329d0d241b6235cde9c84d3445b82f HLS: documented the "hls_forward_args" directive. diff -r 15f78372b132 -r 8cb0c634ff97 xml/en/docs/http/ngx_http_hls_module.xml --- a/xml/en/docs/http/ngx_http_hls_module.xml Sat Apr 05 12:00:30 2014 +0400 +++ b/xml/en/docs/http/ngx_http_hls_module.xml Wed Mar 26 13:51:42 2014 +0400 @@ -9,7 +9,7 @@ + rev="3">
@@ -102,6 +102,97 @@ + +on | off +off +http +server +location +1.5.13 + + +Adds arguments from a playlist request to URIs of fragments. +This may be useful for performing client authorization at the moment of +requesting a fragment, or when protecting an HLS stream with the + module. + + + +For example, if a client requests a playlist +http://example.com/hls/test.mp4.m3u8?a=1&b=2, +the arguments a=1 and b=2 +will be added to URIs of fragments after the arguments +start and end: + +#EXTM3U +#EXT-X-VERSION:3 +#EXT-X-TARGETDURATION:15 +#EXT-X-PLAYLIST-TYPE:VOD + +#EXTINF:9.333, +test.mp4.ts?start=0.000&end=9.333&a=1&b=2 +#EXTINF:7.167, +test.mp4.ts?start=9.333&end=16.500&a=1&b=2 +#EXTINF:5.416, +test.mp4.ts?start=16.500&end=21.916&a=1&b=2 +#EXTINF:5.500, +test.mp4.ts?start=21.916&end=27.416&a=1&b=2 +#EXTINF:15.167, +test.mp4.ts?start=27.416&end=42.583&a=1&b=2 +#EXTINF:9.626, +test.mp4.ts?start=42.583&end=52.209&a=1&b=2 + +#EXT-X-ENDLIST + + + + +If an HLS stream is protected with the +ngx_http_secure_link_module +module, $uri should not be used in the + +expression because this will cause errors when requesting the fragments. +Base URI should be used +instead of $uri +($hls_uri in the example): + +http { + ... + + map $uri $hls_uri { + ~^(?<base_uri>.*).m3u8$ $base_uri; + ~^(?<base_uri>.*).ts$ $base_uri; + default $uri; + } + + server { + ... + + location /hls { + hls; + hls_forward_args on; + + alias /var/videos; + + secure_link $arg_md5,$arg_expires; + secure_link_md5 "$secure_link_expires$hls_uri$remote_addr secret"; + + if ($secure_link = "") { + return 403; + } + + if ($secure_link = "0") { + return 410; + } + } + } +} + + + + + + time 5s diff -r 15f78372b132 -r 8cb0c634ff97 xml/ru/docs/http/ngx_http_hls_module.xml --- a/xml/ru/docs/http/ngx_http_hls_module.xml Sat Apr 05 12:00:30 2014 +0400 +++ b/xml/ru/docs/http/ngx_http_hls_module.xml Wed Mar 26 13:51:42 2014 +0400 @@ -9,7 +9,7 @@ + rev="3">
@@ -102,6 +102,97 @@ + +on | off +off +http +server +location +1.5.13 + + +Добавляет аргументы из запроса плейлиста в URI фрагментов. +Это может быть необходимо для авторизации клиента +во время запроса фрагментов, а также для защиты HLS-потока с помощью +модуля . + + + +Например, если клиент запрашивает плейлист +http://example.com/hls/test.mp4.m3u8?a=1&b=2, +то аргументы a=1 и b=2 +будут добавлены в URI фрагментов после аргументов +start и end: + +#EXTM3U +#EXT-X-VERSION:3 +#EXT-X-TARGETDURATION:15 +#EXT-X-PLAYLIST-TYPE:VOD + +#EXTINF:9.333, +test.mp4.ts?start=0.000&end=9.333&a=1&b=2 +#EXTINF:7.167, +test.mp4.ts?start=9.333&end=16.500&a=1&b=2 +#EXTINF:5.416, +test.mp4.ts?start=16.500&end=21.916&a=1&b=2 +#EXTINF:5.500, +test.mp4.ts?start=21.916&end=27.416&a=1&b=2 +#EXTINF:15.167, +test.mp4.ts?start=27.416&end=42.583&a=1&b=2 +#EXTINF:9.626, +test.mp4.ts?start=42.583&end=52.209&a=1&b=2 + +#EXT-X-ENDLIST + + + + +Если HLS-поток защищён с помощью модуля +ngx_http_secure_link_module, +переменную $uri не следует использовать в выражении +, +так как это приведёт к ошибкам при запросах к фрагментам. +Вместо $uri следует использовать +базовую часть URI +($hls_uri в примере): + +http { + ... + + map $uri $hls_uri { + ~^(?<base_uri>.*).m3u8$ $base_uri; + ~^(?<base_uri>.*).ts$ $base_uri; + default $uri; + } + + server { + ... + + location /hls { + hls; + hls_forward_args on; + + alias /var/videos; + + secure_link $arg_md5,$arg_expires; + secure_link_md5 "$secure_link_expires$hls_uri$remote_addr secret"; + + if ($secure_link = "") { + return 403; + } + + if ($secure_link = "0") { + return 410; + } + } + } +} + + + + + + время 5s