Hi. There are many code samples on the web for simple hotlinking.
I have some questions on how to do this in a better way, and all my
trial code has not worked, so hope some Nginx guru here can help.
Here’s what I am looking for:
-
Firstly, I would like the blocking to happen at a server-wide level.
Nginx is on a dedicated server, and there are many “server” vhost tags
in a folder. I prefer not to have to write the blocking code for every
server individually. Is this possible at an “http” level? What’s the
code for that. -
Secondly, I have about 35 domains and many subdomains. I don’t want
them to be in one long line. But all my “vhost” server tags are inside a
directory. Can I somehow specify Nginx to allow all those domains whose
server definitions are in a folder? (/etc/nginx/vhosts) -
Will the “IF” condition slow down my Nginx? I remember reading that
Nginx does not like IF conditions. -
I want to allow some additional domains like Google and Facebook and
Pinterest. What’s a good way to include this in the allowable list. -
Finally, if I do have to include this directive in each “server”
block for each of my domains, can I at least bundle the commands for
these type of files as such:
`------
location ~* .(png|gif|jpg|jpeg|swf|ico|)$ {
expires 7d;
try_files $uri @backend;
valid_referers none blocked site.com mysite.com ~\.google\.
~.yahoo. ~.bing. ~.facebook. ~.fbcdn.;
if ($invalid_referer) {
return 403;
}
}
------`
Thanks!
Posted at Nginx Forum: