People hotlinking your content on their websites can be pretty annoying, especially if you don’t have a flat-fee traffic contract. The following will explain how to hotlink protection for .

Add the following in your {} context:

location ~* \.(jpg|jpeg|png|gif)$ {
 valid_referers none blocked www.gocit.vn gocit.vn;
 if ($invalid_referer) { return 403; }
}

The above code will prevent hot-linking images (with the extention jpg, jpeg, png and gif) from your website.

You can also (instead of returning a 403 Forbidden) send another image, with this code (again, put it in the server{} context):

location ~* \.(jpg|jpeg|png|gif)$ {
 valid_referers none blocked www.gocit.vn gocit.vn;
 if ($invalid_referer) {
  rewrite (.*)\.(jpg|jpeg|png|gif)$ http://www.gocit.vn/banner.jpg last;
 }
}

The above are just simple examples. You can add extentions to the examples (f.e. .flv, .mp4 etc) to protect even more files from your server.

Print Friendly, PDF & Email

Comments

comments

Bài viết liên quan