nginx 防盗链

 1     server {
 2         listen       80;
 3         server_name  www.zhishaofei.com;
 4 
 5         #charset koi8-r;
 6 
 7         #access_log  logs/host.access.log  main;
 8 
 9         location / {
10             root   html;
11             index  index.html index.htm;
12         }
13 
14         #error_page  404              /404.html;
15 
16         # redirect server error pages to the static page /50x.html
17         #
18         error_page   500 502 503 504  /50x.html;
19         location = /50x.html {
20             root   html;
21         }
22 
23         location ~ .*.(html|htm|gif|jpg|jpeg|png|ico|txt|js|css|swf|flv)$ {
24             valid_referers none blocked *.zhishaofei.com;
25             if ($invalid_referer) {
26                 return 403; 
27             }
28             expires     30d;
29         }
30 
31 }
原文地址:https://www.cnblogs.com/zhishaofei/p/13755733.html