How to block non local refferers to an object?

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…

Regards,
Sam

On 22 Abr 2012 23h09 CEST, [email protected] 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. Module ngx_http_referer_module

— appa