location ~* ^.+\.(gif|jpg|mpg|mp3|mpeg|avi|flv)$ { valid_referers none blocked domain.com www.domain.com; if ($invalid_referer) { return 403; } }