方案一:
# location /images/ { location ~* .*\.(gif|jpg|png)$ { valid_referers none blocked 80boy.com *.80boy.com; if ($invalid_referer) { return 403; # rewrite ^/ http://www.80boy.com/403.jpg; } }
语法:valid_referers none
| blocked
| server_names
| string
...;
none:请求头中缺少 Referer 字段;
blocked:请求头中存在 Referer 字段,但其值已被防火墙或代理服务器删除;这些值都不以 http:// 或 https:// 开头;
server_names:"Referer" 请求头字段包含的服务器名称之一;
方案二:
原文:https://www.cnblogs.com/so-la/p/14723483.html