Nginx hotlinking prevention

hotlinkingnginxvideo

I know this is quite a basic question, but whereas i had no problem preventing image files from hotlinking, i can't figure out how i can't protect mp4 video files…

i just tried to specify mp4 next to jpg, (that's the two filetypes i need to protect), but as it works for jpg, mp4 does nothing !

Any idea ?

location ~* \.(jpg|mp4)$ {
valid_referers none blocked www.mysite.com mysite.com;
if ($invalid_referer) { return 403; }
}

Best Answer

Unfortunately whatever method you use to "protect" the progressive download, it can still be thwarted.

This problem is, that videos are specified as streaming contents.

Actually, many video-downloader tools are so powerful, so it is very difficult to protect the video files from being downloaded.

Usually, there is a three step solution:

  1. GET /path/to/file - return an HTML form with a capcha or some other method to avoid automa
  2. POST /path/to/file - return an HTTP redirect using a secure hash
  3. GET /path/to/file?hash=xxx - check the hash

You can perfect this method by implementing the H264 Streaming Module for nginx.

Related Topic