导读 | 本文教你如何在Nginx上实现防盗链。 |
一、ngx_http_referer_module(阻挡来源非法的域名请求),配置如下:
location ~.*/. (gif|jpg|png|flv|swf|rar|zip)$ { valid_referers none blocked test.com *.test.com; if($valid_referer) { #return 403; rewrite ^/ http://www.test.com/403.jpg; } }
二、HttpAccessKeyMoudule,配置如下:
location ~.*/. (gif|jpg|png|flv|swf|rar|zip)$ { accesskey on; accesskey_hashmethod md5; accesskey_arg "key"; accesskey_signature "mypass$remote_addr"; }
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/121603.html