开发者

nginx: location condition + secure_link

开发者 https://www.devze.com 2023-03-03 09:55 出处:网络
I have a hard time figuring out the correct configuration. I have an URL - e.g. http://example.com/[md5-checksum]/[num-value-1]/[num-value-2]/[file-name]

I have a hard time figuring out the correct configuration.

I have an URL - e.g.

http://example.com/[md5-checksum]/[num-value-1]/[num-value-2]/[file-name]
http://example.com/ac64392dba67d618ea6a76843c006708/123/56789/test.jpg

I want to make sure that the md5-checksum matches salt + num-value-2. So the file name and num-value-1 should be ignored (only needed for the filename header) in order to build the md5 checksum.

Following configuration does not result in what I want to achieve.

location ~* ^/download/([a-zA-Z0-9]+)/([0-9]+)/([0-9]+)/(.*)$ {

   secure_link $3;
   secure_link_md5 segredo$3;

   if ($secure_link = "") {
      return 500;
   }

   set $filename $4;
   add_header Content-Disposition "attachment开发者_JAVA百科; filename=$filename";
   rewrite ^/download/([a-zA-Z0-9]+)/([0-9]+)/([0-9]+)/(.*)$ /$2/$3 break;

}

I appreciate any help!


secure_link $3

should have been

secure_link $1
0

精彩评论

暂无评论...
验证码 换一张
取 消