title: Nginx mp4 hotlink protection doesnt work
body: <p>I am trying to block hotlinking of my mp4 with nginx "valid_referers" :</p>
  
  <pre><code>valid_referers none blocked mysite.com;
              if ($invalid_referer) {
                  return   403;
              }
  </code></pre>
  
  <p>But it doesnt work at all, the mp4 still display on the websites who are stealing the video and if I put some random domain instead of "mysite.com" the video still work.</p>
  
  <p>If it can help, this is what my server conf file look like :</p>
  
  <pre><code>server {
      listen   80;
      server_name dl.mysite.com;
      root /home/videos;
  
      index index.php index.html;
  
      autoindex off; 
  
      location ~ /\. {
          deny all;
      }
  
      # serve static files directly
      location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
          access_log off;
          expires max;
      }
  
      # streaming
      location ~ \.mp4$ {
  
          valid_referers none blocked mysite.com;
          if ($invalid_referer) {
              return   403;
          }
  
          gzip off;
          gzip_static off;
  
          mp4;
          mp4_buffer_size 1M;
          mp4_max_buffer_size 300M;
      }
  
      location ~ .flv$ {
          flv;
      }
  
      # removes trailing slashes
      if (!-d $request_filename)
      {
          rewrite ^/(.+)/$ /$1 permanent;
      }
  
  
      # canonicalize codeigniter url end points
      if ($request_uri ~* ^(/lobby(/index)?|/index(.php)?)/?$)
      {
          rewrite ^(.*)$ / permanent;
      }
  
      # removes trailing "index" from all controllers
      if ($request_uri ~* index/?$)
      {
          rewrite ^/(.*)/index/?$ /$1 permanent;
      }
  
      # unless the request is for a valid file (image, js, css, etc.), send to bootstrap
      if (!-e $request_filename)
      {
          rewrite ^/(.*)$ /index.php?/$1 last;
          break;
      }
  
      # catch all
      error_page 404 /index.php;
  
          location ~ \.php$ {
          try_files $uri =404;
                  fastcgi_pass 127.0.0.1:9000;
                  fastcgi_index index.php;
                  fastcgi_read_timeout 600;
                  include fastcgi_params;
          }
  
  }
  </code></pre>
  
  <p>I am doing something wrong ?</p>