我添加的Nginx conf文件
location /hls {
secure_link $arg_token,$arg_expires;
secure_link_md5 "$secure_link_expires $remote_addr VERY_COOL_SECRET";
if ($secure_link = "") { return 403; }
if ($secure_link = "0") { return 410; }.......
...... 我的PHP代码
<?php
/**
* @param $baseUrl - non protected part of the URL including hostname, e.g. http://example.com
* @param $path - protected path to the file, e.g. /downloads/myfile.zip
* @param $secret - the shared secret with the nginx server. Keep this info secure!!!
* @param $ttl - the number of seconds until this link expires
* @param $userIp - IP of the user allowed to download
* @return string
*/
function buildSecureLink($baseUrl, $path, $secret, $ttl, $userIp)
{
$expires = time() + $ttl;
$md5 = md5("$expires$path$userIp $secret", true);
$md5 = base64_encode($md5);
$md5 = strtr($md5, '+/', '-_');
$md5 = str_replace('=', '', $md5);
return $baseUrl . $path . '?md5=' . $md5 . '&expires=' . $expires;
}
// example usage
$secret = 'VERY_COOL_SECRET';
$baseUrl = 'http://example.com';
$path = '/hls/12.m3u8';
$ttl = 120; //no of seconds this link is active
$userIp = $_SERVER['REMOTE_ADDR'];
$url = buildSecureLink($baseUrl, $path, $secret, $ttl, $userIp);
?>
当我在视频源中使用$ url时,会向我显示一个安全的URL,但未播放视频。 在安装或配置Nginx时,我还会添加--with-http_secure_link_module。你能帮我么 预先感谢