A few clients have recently complained about other blogs linking to their images and leeching off their bandwidth. Bandwidth is expensive and should be protected.
Here’s a working solution:
location ~ \.(jpg|jpeg|bmp|jif|bmp|gif|png)$ {
root /path/to/public_html/;
valid_referers server_names none blocked;
if ($invalid_referer) {
return 403;
}
}
Some sites will need to allow some other sites to link to their images. If this is the case you can use the following rewrites – just modify and add domains as required
location ~ \.(jpg|jpeg|bmp|jif|bmp|gif|png)$ {
root /path/to/public_html/;
valid_referers server_names none blocked www.theothersite.com *.theothersite.com;
if ($invalid_referer) {
return 403;
}
}



It still not working. Other can leeching my files. Sorry for my bad english.
location ~ \.(gif|jpg|jpeg|png|js|css|rar|exe|sis|sisx|swf|txt|tpl)$ {
root /home/skedteam/www/public_html/;
valid_referers server_names none blocked ~\.google\. images.yandex.ru;
if ($invalid_referer) {
return 403;
}
}
Try removing the wildcard google exception and see if it works. My guess is that the syntax isn’t quite right.