[HOW-TO] Prevent Hotlink in Drupal 6 + Nginx - 2nd Method

By BXTra |

After tried [HOW-TO] Prevent Hotlink in Drupal 6 + Nginx for a few days. I found a second method which is very similar to the first method but the different is in valid_referers.

Nginx Vhost configuration file - Protect hotlink (regexp)

valid_referers none blocked server_names 
if ($invalid_referer) { 	
     rewrite ^/files.*\.(gif|jpg|jpeg|png|bmp)$ http://www.domainname.com/nohotlink.gif last;

Above code, you allow domainname.com to hotlink your images. You also allow google with any top level domain like google.com, google.de, www.google.com, images.google.com, etc. to hotlink your images. Bing is also allowed here.

Source :
- http://linuxsysadminblog.com/2009/08/using-wildcards-in-nginx-valid_referers/

Add new comment

  • No HTML tags allowed.
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.