Моя Nginx secure_link не работает, Показать защищенный URL, но видео не воспроизводится - PullRequest
0 голосов
/ 02 января 2019

Мой файл конфигурации Nginx, который я добавляю

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, но видео не воспроизводится.Я также добавляю --with-http_secure_link_module при установке или настройке Nginx.Не могли бы вы помочь мне, спасибо заранее

...