S
S
StynuBlizz2017-07-12 13:49:37
Nginx
StynuBlizz, 2017-07-12 13:49:37

nginx_http_secure_link_module not working. Where is the error?

I'm trying to run this module with minimal functionality. And it constantly throws a 403 error. How to fix it?
Code in djnago:

hash_for_base = hashlib.md5("1".encode()).hexdigest()
base = base64.b64encode(hash_for_base.encode()).decode()
link = "http://192.168.0.11/dash?hash="+base+"&post_id=1"
return JsonResponse({"dasd": link})

nginx config:
location /dash {
    secure_link $arg_hash;
    secure_link_md5 $arg_post_id;
    if ($secure_link = ""){ return 403; }
    if ($secure_link = "0"){ return 404; }
    alias /home/max/odin/dva/processed_file/$arg_post_id;
  }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
StynuBlizz, 2017-07-12
@StynuBlizz

post_id = request.POST["post_id"]
hash_for_base = hashlib.md5(post_id.encode()).digest()
base = base64.urlsafe_b64encode(hash_for_base).decode()
link = "http://192.168.0.11/dash?hash="+base+"&postid="+post_id

Here is the code that worked.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question