[root@static ~]# grep -Pv '^$|^ *#' /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
location ~ \.(jpg|png|css|js)$ {
root /usr/share/nginx/html;
valid_referers none blocked www.sharkyun.com;
if ($invalid_referer) {
return 403;
}
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
可以查看日志 /var/log/nginx/access.log
,确认 referer
的值为短横线 -
,也就是 none
cruel -e 参数可以在请求头中设置 referer 的值