Nginx block from referrer

前端 未结 3 688
长情又很酷
长情又很酷 2021-02-06 13:04

I need block all http connections, who have referrer click2dad.net. I write in mysite.conf:

 location / {
            valid_referers ~.*http://click2dad\\.net.*;         


        
3条回答
  •  花落未央
    2021-02-06 13:46

    It should be noted that an expression will be matched against the text starting after the “http://” or “https://” http://nginx.org/en/docs/http/ngx_http_referer_module.html

    Correct config:

     location / {
                valid_referers click2dad.net*;
                if ($invalid_referer = ''){
                        return 403;
                }
                try_files       $uri    $uri/   /index.php?$args;
        }
    

提交回复
热议问题