<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi,<div class=""><br class=""></div><div class="">Actually you can use a module developed by Kaltura call secure token module (1). This module can examine your response to see its content-type, if it matches configured parameter, it will automatically inject secure params into hls playlist. Use this module, please note you dont use anything relate to uri in secure link (ie: dont use $uri to calculate secure link)</div><div class=""><br class=""></div><div class="">(1): <a href="https://github.com/kaltura/nginx-secure-token-module" class="">https://github.com/kaltura/nginx-secure-token-module</a></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jun 17, 2019, at 3:17 PM, Andrew Andonopoulos <<a href="mailto:andre8525@hotmail.com" class="">andre8525@hotmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">Hi Francis and thank you for your quick response / support.</div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""><br class=""></div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">Now is more clear how locations and secure link works. </div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""><br class=""></div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">I would like to add the secure link in each m3u8 and ts file but can't modify the files on the fly with the free nginx version, i think nginx plus have this capability ? (receive fmp4 and deliver manifests on the fly)</div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""><a href="https://www.nginx.com/products/nginx/streaming-media/" id="LPNoLP892346" class="">https://www.nginx.com/products/nginx/streaming-media/</a><br class=""></div><br style="caret-color: rgb(0, 0, 0); font-family: SourceCodePro-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">What you would suggest in case i want to use secure link for all the files?</div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""><br class=""></div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""><br class=""></div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">Thanks</div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">Andrew</div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""><br class=""></div><div style="caret-color: rgb(0, 0, 0); font-family: SourceCodePro-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><div id="appendonsend" class=""></div><div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""><br class=""></div><div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""><br class=""></div><div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""><br class=""></div><div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""><br class=""></div><hr tabindex="-1" style="display: inline-block; width: 1189.71875px;" class=""><div id="divRplyFwdMsg" dir="ltr" class=""><font face="Calibri, sans-serif" style="font-size: 11pt;" class=""><b class="">From:</b><span class="Apple-converted-space"> </span>nginx <<a href="mailto:nginx-bounces@nginx.org" class="">nginx-bounces@nginx.org</a>> on behalf of Francis Daly <<a href="mailto:francis@daoine.org" class="">francis@daoine.org</a>><br class=""><b class="">Sent:</b><span class="Apple-converted-space"> </span>Monday, June 17, 2019 7:40 AM<br class=""><b class="">To:</b><span class="Apple-converted-space"> </span><a href="mailto:nginx@nginx.org" class="">nginx@nginx.org</a><br class=""><b class="">Subject:</b><span class="Apple-converted-space"> </span>Re: Securing URLs with the Secure Link Module in NGINX</font><div class=""> </div></div><div class="BodyFragment"><font size="2" class=""><span style="font-size: 11pt;" class=""><div class="PlainText">On Sat, Jun 15, 2019 at 06:08:07PM +0000, Andrew Andonopoulos wrote:<br class=""><br class="">Hi there,<br class=""><br class="">> In my case the player will request the m3u8 URL:<br class="">><span class="Apple-converted-space"> </span><br class="">> https://<domain>/hls/justin-timberlake-encrypted/playlist.m3u8?md5=u808mTXsFSpZt7b8wLvlIw&expires=1560706367<br class="">><span class="Apple-converted-space"> </span><br class="">> The response from the server will be:<br class="">><span class="Apple-converted-space"> </span><br class="">> #EXTM3U<br class="">> #EXT-X-VERSION:3<br class="">> #EXT-X-STREAM-INF:BANDWIDTH=200000,RESOLUTION=416x234<br class="">> Justin_Timberlake_416_234_200.m3u8<br class="">> #EXT-X-STREAM-INF:BANDWIDTH=300000,RESOLUTION=480x270<br class="">> Justin_Timberlake_480_270_300.m3u8<br class=""><br class="">> Can I instruct Nginx to use secure link only for the playlist.m3u8 and not for the other m3u8 and ts files?<br class=""><br class="">Yes.<br class=""><br class="">I am not sure why you would do that; or what benefit it will give you;<br class="">but that's ok. I do not need to understand that part.<br class=""><br class=""><br class="">In nginx, a request in handled in a location.<br class=""><br class="">So you want one location that will handle playlist.m3u8 requests and<br class="">does the secure_link thing; and a separate location that will handle<br class="">all of the other /hls/ requests.<br class=""><br class="">I think you want to proxy_pass all of the requests, so you need proxy_pass<br class="">in both locations.<br class=""><br class="">I think you want lots of common config -- add_header, proxy_hide_header --<br class="">so it is probably simplest to use nested locations to allow inheritance<br class="">rather than duplication.<br class=""><br class="">For example (untested):<br class=""><br class=""> location /hls/ {<br class=""><br class=""> # all of the common config goes here<br class=""><br class=""> proxy_pass<span class="Apple-converted-space"> </span><a href="http://s3test.s3.amazonaws.com/" class="">http://s3test.s3.amazonaws.com</a>;<br class=""><br class=""> location ~ /playlist\.m3u8$ {<br class=""> secure_link $arg_md5,$arg_expires;<br class=""> secure_link_md5 "enigma$hls_uri$secure_link_expires";<br class=""><br class=""> if ($secure_link = "") { return 403; }<br class=""> if ($secure_link = "0") { return 410; }<br class=""> proxy_pass<span class="Apple-converted-space"> </span><a href="http://s3test.s3.amazonaws.com/" class="">http://s3test.s3.amazonaws.com</a>;<br class=""> }<br class=""><br class=""> }<br class=""><br class="">Adjust to fit the rest of your requirements.<br class=""><br class="">Good luck with it,<br class=""><br class=""> f<br class="">--<span class="Apple-converted-space"> </span><br class="">Francis Daly <a href="mailto:francis@daoine.org" class="">francis@daoine.org</a><br class="">_______________________________________________<br class="">nginx mailing list<br class=""><a href="mailto:nginx@nginx.org" class="">nginx@nginx.org</a><br class=""><a href="http://mailman.nginx.org/mailman/listinfo/nginx" class="">http://mailman.nginx.org/mailman/listinfo/nginx</a><br class=""></div></span></font></div></div><span style="caret-color: rgb(0, 0, 0); font-family: SourceCodePro-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">_______________________________________________</span><br style="caret-color: rgb(0, 0, 0); font-family: SourceCodePro-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: SourceCodePro-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">nginx mailing list</span><br style="caret-color: rgb(0, 0, 0); font-family: SourceCodePro-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><a href="mailto:nginx@nginx.org" style="font-family: SourceCodePro-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">nginx@nginx.org</a><br style="caret-color: rgb(0, 0, 0); font-family: SourceCodePro-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><a href="http://mailman.nginx.org/mailman/listinfo/nginx" style="font-family: SourceCodePro-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">http://mailman.nginx.org/mailman/listinfo/nginx</a></div></blockquote></div><br class=""></div></body></html>