Welcome! Log In Create A New Profile

Advanced

Вопрос по HttpSecureLinkModule

December 27, 2011 04:42AM
Помогите пожалуйста разобраться с HttpSecureLinkModule. Делаю все по инструкции http://wiki.nginx.org/HttpSecureLinkModule, но почему-то не получается.

Задача: отдавать по разным ссылкам видео в зависимости от IP юзера.

Создаю локейшен:
location /video/ {
## This must match the URI part related to the MD5 hash and expiration time.
secure_link $arg_st;

## This is how the MD5 hash is built from a secret token, an URI and an
## expiration time.
secure_link_md5 qp3mc84ha0m46c$uri$remote_addr;

## If the hash is incorrect then $secure_link is a null string.
if ($secure_link = "") {
return 403;
}

## The current local time is greater than the specified expiration time.
if ($secure_link = "0") {
return 403;
}

## If everything is ok $secure_link is 1.
}

Делаю /etc/init.d/nginx reload чтобы подхватить новый конфиг.

Создаю в каталоге qp3mc84ha0m46c/video/files/ файл top_secret.pdf

Для проверки генерю вручную нужную ссылку, по которой он должен отдаваться:
php -r 'print str_replace("=", "", strtr(base64_encode(md5("qp3mc84ha0m46c/video/files/top_secret.pdf46.185.43.130", TRUE)), "+/", "-_")) . "\n";'
где 46.185.43.130 - мой IP.
Получается:
1aucwvhDHWfwAaDJuw1QrQ

Потом пробую получить файл:
http://site.ru/video/files/top_secret.pdf?st=1aucwvhDHWfwAaDJuw1QrQ
В результате 404 Not Found nginx/1.0.6
А так http://site.ru/qp3mc84ha0m46c/video/files/top_secret.pdf - все нормально - 200 с отдачей файла.

Что я делаю не так?
Subject Author Posted

Вопрос по HttpSecureLinkModule

valet December 27, 2011 04:42AM

Re: Вопрос по HttpSecureLinkModule

valet December 27, 2011 06:04AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 297
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready