Knowledgebase:
Nginx Secure Streaming
Posted by Konrad Piwowar, Last modified by Konrad Piwowar on 01 November 2018 02:06 PM
The enable nginx secure streaming, please do the following:

In your nginx.conf inside the server{} for the virtualhost you are working on, add:

location /media/videos/ {
   secure_link $arg_md5,$arg_expires;
   secure_link_md5 "$secure_link_expires$uri YOURSECRETKEY";
   if ($secure_link = "") { return 403; }
   if ($secure_link = "0") { return 410; }
}

Inside your admin/functions.custom.php file, add the following function:

if(!function_exists('buildNginxSecureLink')) {
    function buildNginxSecureLink($baseUrl, $path, $secret, $ttl) {
        $expires = time() + $ttl;
        $md5 = md5("$expires$path $secret", true);
        $md5 = base64_encode($md5);
        $md5 = strtr($md5, '+/', '-_');
        $md5 = str_replace('=', '', $md5);
        return $baseUrl . $path . '?md5=' . $md5 . '&expires=' . $expires;
    }
}

Inside your admin/functions.player.php, add the following inside the displayPlayer function for the appropriate player (IE displayPlayerVideoJS):

AFTER:
$outputFiles = getMediaURLs($rrow);

ADD:
foreach($outputFiles as $k=>$v) {
   $outputFiles[$k] = buildNginxSecureLink($basehttp,"/media/videos".str_replace($video_url,"",$v),"YOURSECRETKEY",1800);
}

You must of course replace "YOURSECRETKEY" with a key of your own, and depending on your httpd setup you may need to adjust the paths used in this file.
(1 vote(s))
Helpful
Not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments: