Nginx referer防盗链模块
L75
referer模块 ngx_http_referer_module 默认编译进nginx
valid_referers 指令
Syntax: | valid_referers |
---|---|
Default: | — |
Context: | server , location |
参数值
none 允许缺失referer头部请求访问
block 允许有referer头部请求访问
server_names 如果server_names与本机server_name某个域名匹配则允许访问
正则表达式 匹配上允许访问
域名前缀或后缀匹配上 也允许访问
invalid_referer 变量 允许访问时值是空 不允许访问时值是空
server { server_name xxx.xxxx.com; error_log logs/myerror.log debug; root html; location /{ valid_referers none blocked server_names *.taohui.pub www.taohui.org.cn/nginx/ ~\.google\.; if ($invalid_referer) { return 403; } return 200 'valid\n'; } }
referer_hash_bucket_size 缓存
referer_hash_max_size 缓存最大值