错误:
nginx: [emerg] unknown directive "if($invalid_referer)" in
/usr/local/nginx/conf/nginx.conf:27
代码:
设置有效的refer值
- none:检测地址没有refer,则有效
- server_name:检测主机地址,refer显示是从这个地址来的,则有效(server_name必须是完整的
http://xxxx
)
valid_referers http:192.168.174/134;
if ($invalid_referer){return 403;
}
注意(重要的事情说一遍,很可能忽视):if ($invalid_referer)
中if后有个空格,不写就会报错
参考文档:
1、Nginx之防盗链及高可用解读
2、ngx_http_referer_module模块
3、ngx_http_referer_module模块