Almost two weeks ago I moved my personal blog-project horrorblog.org from a domainfactory managed hosting server to a JiffyBox which is a scalable cloud server solution also by domainfactory. I won’t talk about the setup for now (but later this or next week) but I want to show you an example for a nginx config file that prevents your images from beeing hotlinked but still enabling google and facebook.
Prevent hotlinking in nginx is really simple and some rules and examples can be found via google:
# apply this rule on any location that’s an image using Regexp
location ~* \.(png|gif|jpg|jpeg|swf|ico)(\?[0-9]+)?$ {
# block empty blocked or whiteliste referers
valid_referers none blocked horrorblog.org www.horrorblog.org;
if ($invalid_referer) {
return 403;
}
}
This works fine, unless you won’t have your images displayed on facebook when anybody likes your stuff with the facebook share button (og:image) or in google image search. The solution that enables facebook to grab the images from your host is by adding ~\.facebook\.
and ~\.fbcdn\.
to the whitelist of hosts:
# apply this rule on any location that’s an image using Regexp
location ~* \.(png|gif|jpg|jpeg|swf|ico)(\?[0-9]+)?$ {
# block empty blocked or whiteliste referers
valid_referers none blocked horrorblog.org www.horrorblog.org ~\.google\. ~\.yahoo\. ~\.bing\. ~\.facebook\. ~\.fbcdn\.;
if ($invalid_referer) {
return 403;
}
}
Irgnedwie nervts - ist warscheinlich auch okay - aber wieso suchen so viele leute nach dreadlocks, verlinken dann das bild aus meinem blog ohne mir Bescheid zu geben? hö?
ist es verwerflich die google bilder suche referer auszusperren oder zu versuchen was gegen sie zu unternehmen - weil ja klar ohne rückmeldung was produziert wird was man selbst nicht kontrolliert - oder ist das ok ?
EDIT: Für alle, die es gesehen haben, kurz lag so'n komisches Technocrati Teil über dem Blogeintrag ... det is jetzt aus! haha!