1. 程式人生 > >Nginx referer防盜鏈模塊

Nginx referer防盜鏈模塊

googl 變量 後綴 contex cells val ali 表達 nta

referer模塊 ngx_http_referer_module 默認編譯進nginx

valid_referers 指令

Syntax: valid_referers none | blocked | server_names | string ...;
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 緩存最大值

Nginx referer防盜鏈模塊