主要配置代码如下: location ~*\.(gif|jpg|jpeg|png|bmp|swf)$ { valid_referers none blocked *.linuxeye.com; if ($invalid_referer) { rewrite ^/ http://linuxeye.com/error.html; #return 403; } } 以上代码解释如下: 1、location中指定要防篡改的文件类型; 2、valid_referers指定资源访问是通过以下几种方式为合法 none:直接通过url访问,无referer值的情况 blocked:referer值被防火墙修改 servername:指定资源在合法的url中可以被引用,支持*通配符 3、if判断如果用户请求的资源不符合上述配置,那么rewrite重定向到你想指定的url上,也可以配置403权限错误。 转载请保留固定链接: https://linuxeye.com/configuration/839.html |