flv streaming and proxy_pass

Max maxbear at gmail.com
Thu Feb 19 03:01:43 MSK 2009


Hi,

Do you use this module to stream? http://h264.code-shop.com/trac

This might not useful for you, but just for references.

I use this to stream mp4 movies (h264 video code) with lighttpd(they have a
module for ngnix and apache), it's working great and without any problem.

Max

On Thu, Feb 19, 2009 at 7:15 AM, Karolis D <karolis at pg.lt> wrote:

> On Wed, Feb 18, 2009 at 7:39 PM, Karolis <karolis at pg.lt> wrote:
>
>> hi list,
>>
>> I am using nginx / apache combination to stream flv files.
>> Nginx serves static files and forwards dynamic requests to apache/mod_php.
>>
>> Request flow would be as follows:
>>
>> - client requests some file
>> - nginx rewrites the filename to a local cache dir
>> - if file is found in the cache dir, nginx sends the file
>> - if file is not found, then request is passed to apache, which will
>> create the file and send the contents.
>>
>> For flv files we want flv streaming.
>>
>> The rules I am using to make this work are as follows:
>>
>>   # Map request url to cache dir
>>   location /dbfile {
>>           rewrite  "^/dbfile/([0-9]{3})([0-9]{3})([0-9]{3})/(.*)$"
>> /cache/$1/$2/$1$2$3__$4  last;
>>   }
>>
>>   # Forward PHP requests to apache, in case we don't have cache yet
>>   location ~ ^/cache/ {
>>       if (!-f $request_filename) {
>>           proxy_pass  http://127.0.0.1:8080;
>>       break;
>>       }
>>   }
>>
>>   # Handle FLV streaming
>>   location ~ ^/cache/(.*)\.flv$ { flv; }
>>
>> In this configuration, proxy_pass works, but flv streaming doesn't.
>> If I move FLV "location" directive above proxy_pass, then flv will work,
>> and proxy_pass won't.
>>
>> How do I get them both to work together? I don't want streaming of proxied
>> requests, I only want to
>> flv-stream the files that are on local filesystem.
>>
>> Any help?
>>
>> thanks
>> Karolis
>>
>>
> I've also tried to work around the problem by rewriting flv file to php
> script, and then proxy_pass'ing the php to apache, but the results are no
> better:
>
>     # Map request url to cache dir
>     location ~ ^/dbfile/ {
>             rewrite  "^/dbfile/([0-9]{3})([0-9]{3})([0-9]{3})/(.*)$"
> /cache/$1/$2/$1$2$3__$4  last;
>     }
>
>         # If required cache file does not exist...
>     location ~ ^/cache/ {
>         if (!-f $request_filename) {
>             rewrite "/cache/([0-9]{3})/([0-9]{3})/([0-9]{9})__(.*)$"
> /file.php?id=$3 last;
>         }
>     }
>
>         location ~ ^/cache/(.*)\.flv$ { flv; }
>
>     # Forward PHP requests to Apache
>     location ~ ^/file.php {
>         proxy_pass  http://127.0.0.1:8080; # pass on request to apache
>     }
>
> If I comment out the proxy_pass section, then the FLV streaming starts to
> work fine. So it kind of means nginx doesn't like the proxy part of the
> setup.
>
> I do understand that you can't stream a file that is retrieved from a proxy
> server, but in this setup  I am trying to do only one of those things:
> Either fetch the file from proxy if it doesn't exist locally, or flv-stream
> it if it does exist.
>
> Problem is that lighttpd does it without a problem with mod_magnet :)
>
> Karolis
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20090219/feb4201b/attachment.html>


More information about the nginx mailing list