I want to make a secure URL with Nginx secure-link model and rewrite. So the secured link be like:
http://example.com/media/ZYSwFWTSM8DHh8CNupbbzw/1593525536/videos/tmp/793.mp4
And the Rewrite convert it to:
http://example.com/media/videos/tmp/793.mp4?md5=ZYSwFWTSM8DHh8CNupbbzw&secure=1593525536
So at the end open this video link:
http://example.com/media/videos/tmp/793.mp4
This is my Nginx server config:
location /media {
rewrite /videos/([a-zA-Z0-9_\-]*)/([0-9]*)/tmp/(.*)\.mp4$ /media/videos/tmp/$3.mp4?md5=$1&expires=$2;
}
location /media/videos {
secure_link $arg_md5,$arg_expires;
secure_link_md5 "$secure_link_expires$uri SecretWord";
if ($secure_link = "") { return 403; }
if ($secure_link = "0") { return 410; }
}
The problem is that I getting "403 Forbidden" when I try to open these secured links:
http://example.com/media/ZYSwFWTSM8DHh8CNupbbzw/1593525536/videos/tmp/793.mp4
Although these links are working very well:
http://example.com/media/videos/tmp/793.mp4?md5=ZYSwFWTSM8DHh8CNupbbzw&secure=1593525536
also When I remove the secure_link model config, and try this link:
http://example.com/media/ZYSwFWTSM8DHh8CNupbbzw/1593525536/videos/tmp/793.mp4
The video working.
So I really don't know what is the problem because The rewrite config or secure_link_module working itself but they are not working together.