Q:

Blacklist domains that hotlink to files in a sub-directory - nginx

I am looking to blacklist certain websites from hotlinking to my files in a certain sub-directory. By default, I want to allow everyone but block only certain websites that hotlink without attribution. How can this be done in nginx? Is it possible to achieve it using the valid_referers directive?
http://wiki.nginx.org/Referrer_Spam_Blocking
Please Note: I have seen "how to white list" answers, but that's not what I need.

A:

The only way I was able to block on a referrer domain was to put this in the location block where I wanted them blocked.
if ($http_referer ~* (semalt.com)) { return 403; }

