1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Protect media content on your site

Discussion in 'Server Configuration and Hosting' started by Andy.N, Sep 2, 2011.

  1. Andy.N

    Andy.N Well-Known Member

    I host video clips on my site and display them via embedded player (JW Player).

    Is there anyway via a server script that I can disable people hotlink to the video files or embed the player on other sites. In short, the video can only be played on my site.

    I run nginx, ubuntu by the way.

  2. Deebs

    Deebs Well-Known Member


    Does JW player require the full url or a local path to display the content? I am guessing the local path, if so add this to your nginx config:

            location /path/to/root/of/media/library/ {
    That should work.
  3. Andy.N

    Andy.N Well-Known Member

    It uses local path so I can use "/video/file.mp4" to display. It doesn't take much for people to figure it out the absolute url.

    I assume putting the code that you have will deny access to anyone who go to the files directly?
  4. Deebs

    Deebs Well-Known Member


    Just replace /path/to/root/etc/etc with the absolute path to your media files you want to protect.
  5. Andy.N

    Andy.N Well-Known Member

    What about allows download if the referrer is coming from the site. For example, if users click on a link on my site, they can download it. But if the download link is posted on another forum, they can't download it.

    Is it possible?
  6. Deebs

    Deebs Well-Known Member

    Can you provide urls which describe both actions? (do it via PC if you want).
  7. Andy.N

    Andy.N Well-Known Member

    I don't have any example up to show. Here is what i mean.

    Suppose I have a video clip at www.mysite.com/video/clip1.mp4

    If I post this link on my site, people clicking on it will generate a request to the server with the referrer as "www.mysite.com". The server will then return the file without problem.

    Now, if some people trying to leech and put this link on another forum. Clicking on that link will generate a request to my server that is not coming from "www.mysite.com" but from another site. My server will deny this request.
  8. Jaxel

    Jaxel Well-Known Member

  9. Andy.N

    Andy.N Well-Known Member

    Where do I test this?
    I put
    location /video/(chapter1|chapter2|chapter3|chapter4|chapter5|chapter6)/ {
    in the nginx config, restart nginx. I still can go directly to the video/chapter1/video1.mp4 from the browser.
  10. Deebs

    Deebs Well-Known Member

  11. Andy.N

    Andy.N Well-Known Member

    Yes, I tried that before and did not seem to make a difference
  12. Deebs

    Deebs Well-Known Member


    location /video/ {
      deny all;
  13. Andy.N

    Andy.N Well-Known Member

    Does it make a difference to you?
  14. Deebs

    Deebs Well-Known Member

    No, that should match on that location. Let's take it to PM, can you give me your config minus any sensitive stuff?
    Andy.N likes this.
  15. Deebs

    Deebs Well-Known Member

    On my dev server I uploaded a video to


    when I went to http://blah/data/local/cp.mp4 it allowed me to download the video. I added the following:

            location /data/local/ {
    Now when I goto http://blah/data/local/cp.mp4 I get a 404 error returned by nginx.
  16. Floris

    Floris Guest

    You can perhaps try to lower the default ripping, but no. You can't prevent it. One can just point a screen recorder to the media.
  17. Deebs

    Deebs Well-Known Member

    Don't worry Floris, the experts are on it. (Had to bite my tongue here :( )
  18. Andy.N

    Andy.N Well-Known Member

    The issue is still open. Any suggestion welcome.
    Thanks to Deebs who has helped a lot with many other issues on the server.
  19. Blandt

    Blandt Well-Known Member

    Deebs suggestion is the way to go in preventing hot linking. Preventing download is another issue and you cannot do it unless you host your videos in a dedicated flash / silverlight server.
  20. Blandt

    Blandt Well-Known Member

    Why don't you use Vimeo.com ?

Share This Page