[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 的值