How to block non local refferers to an object?

António P. P. Almeida appa at perusio.net
Sun Apr 22 21:26:12 UTC 2012


On 22 Abr 2012 23h09 CEST, tdgh2323 at hotmail.com wrote:


>
> Hello Community,
>
> Could anybody please give me an example (or point me to such) on
> best way to block non local referrers to my image files (jpg, jpeg,
> gif)
>
> Thanks.. 

location ~* \.(?:gif|jpe?g|png)$ {
    valid_referers none blocked *.example.* *.google.* my.site.com;

    if ($invalid_referer) {
       return 200 "No image hotlinking allowed!\n";
    }
}

Cf. http://nginx.org/en/docs/http/ngx_http_referer_module.html

--- appa



More information about the nginx mailing list