以前介绍过Nginx防盗链(二)
这种方法可能出现key对不上而发生403的问题,对于这个问题,只能换key了,不用$remote_addr,那用什么呢?Cookie是个不错的选择,于是配置可以改成下面这样:
if ($http_cookie ~* "ng_cookie=(.+?)(?:;|$)") { set $ng_cookie $1; } location /download { accesskey on; accesskey_hashmethod md5; accesskey_arg "key"; accesskey_signature "mypass$ng_cookie"; error_page 404 =200 /$request_uri; }