mancha 发表于 2016-12-24 08:23:35

Nginx防盗链(三)

  以前介绍过Nginx防盗链(二)
  这种方法可能出现key对不上而发生403的问题,对于这个问题,只能换key了,不用$remote_addr,那用什么呢?Cookie是个不错的选择,于是配置可以改成下面这样:

if ($http_cookie ~* "ng_cookie=(.+?)(?:;|$)")
{
set $ng_cookie $1;
}
location /download {
accesskey             on;
accesskey_hashmethodmd5;
accesskey_arg         "key";
accesskey_signature   "mypass$ng_cookie";
error_page 404 =200 /$request_uri;
}
页: [1]
查看完整版本: Nginx防盗链(三)