Answer the question
In order to leave comments, you need to log in
Each user has a unique link to the file[NGINX, PHP]
Hello Jedi.
We set a task, I solve it not for the first day, but I can’t cope with it.
Task:
Each user is given a video file unique for him, like domen.tv/video/{hash}/file.mp4(flv)
hash consists of the user's ip and salt.
It is necessary that this link opens only for this user.
The file storage structure is as follows (you can change it):
domen
- php scripts
videofiles
- 1000
- - 24
- - - file.mp4
Answer the question
In order to leave comments, you need to log in
There is such a module:
wiki.nginx.org/HttpSecureDownload
And another one:
wiki.nginx.org/HttpSecureLinkModule
To use the second one, you will need to write some code that will generate tokens (all this is described in the link).
Use the X-Accel-Redirect header.
For this location, in which the files are actually located, mark as internal:
location /videofiles {
root /var/www;
internal;
}
<?php
// Здесь проверяете, есть ли у пользователя доступ
header("X-Accel-Redirect: /videofiles/" . $path);
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question