mardi 20 septembre 2016

Stream video/audio content from nginx using symlinks

So I have what I think is a fairly specific problem. I have nginx configured as follows.

 http {
     tcp_nopush on;
     tcp_nodelay on;
     keepalive_timeout 65;
     types_hash_max_size 2048;

     include /etc/nginx/mime.types;
     default_type application/octet-stream;

     disable_symlinks off;

     gzip on;
     gzip_disable "msie6";

     server {
         listen 9000;

         location / {
             alias /path/to/sym-links/directory/;
         }
     }
 }

So as a bit of background on this, I am trying to use symlinks to point to video/audio assets on my server which I will then plug into html5 audio / video players. My issue is that whenever I go to localhost:9000/some-sym-link.avi, the asset immediately initiates a download. What I want the server to do is figure out which video/audio file the sym link points to, and stream that file over HTTP, but again it simply downloads the file straight to my internet browser without a stream.

If the flow is still unclear, let me offer a step by step overview.

  1. User makes request to localhost:9000/some-sym-link.avi
  2. Nginx receives request and notices asset is a symlink.
  3. Nginx STREAMS the asset pointed to by the symlink (does not initiate download)
  4. Then the stream can be plugged into audio / video players etc.

If I create a video tag like such

<video width="320" height="240" controls="">
    <source src="http://localhost:9000/some-sym-link.avi">
</video>

It doesn't play anything (I figure because the asset stream is not working correctly).

Any help on this would be extremely welcome. Thanks :)




Aucun commentaire:

Enregistrer un commentaire