2

I config a location in nginx follow:

location /download {
    secure_link $arg_key,$arg_expires;
    secure_link_md5 "$secure_link_expires$uri$remote_addr download";

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

    if ($secure_link = "0") {
        return 410;
    }


    set_unescape_uri $key $arg_key;
    set_unescape_uri $value $arg_expires;
    redis2_query setnx $key $value;
    redis2_pass 127.0.0.1:6379;

    proxy_pass http://172.16.10.134/$uri;
    proxy_set_header       Host $host;
    proxy_cache            $STATIC;
    proxy_cache_valid      200  1d;
    proxy_cache_use_stale  error timeout invalid_header updating
                               http_500 http_502 http_503 http_504;
    proxy_cache_min_uses   3;
    proxy_cache_key        $request_uri;
}

In this config, I want to secure link with module secure_link and it work perfectly. now I try to improve it with more secure by using one key for one link. I add some line :

set_unescape_uri $key $arg_key;
set_unescape_uri $value $arg_expires;
redis2_query setnx $key $value;
redis2_pass 127.0.0.1:6379;

command : redis2_query setnx $key $value will return 1 if key not exist, 0 if key have already. and I want to set a variable to take this value then return 403 for user. any body have idea for this? thanks

1
  • How did u solve this? Jun 19, 2020 at 13:27

0

You must log in to answer this question.

Browse other questions tagged .