0

I implemented Nginx secure link module but can not get it working. I did read many posts on Serverfaulty and Stackowerflow but no success.

I want to restrict access to any full size /image/video files in directories:

/u/folder1/name.jpg
/u/folder2/name.mp4

at the same time I want to allow access to the thumbnails located

/u/folder1/thumb1/name.jpg
/u/folder1/thumb2/name.mp4

etc.

I tried different variants and this is the last:

location  ^/u/[0-9a-z]+/\.(jpg|mp4)$ {

secure_link $arg_cdg,$arg_expires;
secure_link_md5 "$secure_link_expires$uri$remote_addr xxx";
if ($secure_link = "") { return 403; }
if ($secure_link = "0") { return 410; }
}

Actually, I don't need to list file types - I want to restrict access to any files in the second level subfolders - /u/anyfolder/anyfilename

Any help?

Tfsur
  • 3
  • 1
  • 2

1 Answers1

0

With these locations, anything in subfolders of /u/folder1 should be accessible, anything in /u/folder1 itself, not.

    location ~ ^/u/folder1/.+/ {
      try_files $uri $uri/ =404;
    }

    location ~ ^/niv1/[^/]* {
      return 403;
    }
Gerard H. Pille
  • 2,569
  • 1
  • 13
  • 11