Change website

From Jan 16 2015,


All post content will be move to we's offical website with many content...

Can access website here: http://justox.com

Thanks for your visit!

Wednesday, 18 December 2013

Nginx Hotlink Protection And How To Use It

Source Wikipedia :
Hotlinking is a term used on the Internet that refers to the practice of displaying an image on a website by linking to the same image on another website, rather than saving a copy of it on the website on which the image will be shown.
Hotlinking can be major issue for bandwidth leeching for some sites. Here is small config part which you can add to prevent those activities.

server {
    location ~ \.(mp4|mp3|wav|avi)$ {
        valid_referers blocked example.com *.example.com;
        if ($invalid_referer) {
            return   403;
        }
    }
}
To specify more file types you need to use pipe “|”.
Also you will notice that i didn’t put “none” in valid_referers, this is because you can fake null referrer and anyone could access your protected files and leech it again without your approval.
You can add those directive in folder too so you will not need to specify extension/s eg. location /videos/ { .. } and this will protect any file inside this directory.
Notice :
You should consider to remove “none” from valid_referers because some browsers like IE can not understand this redirect.

No comments:

Post a Comment