flv streaming and proxy_pass

Kamil Gorlo kgorlo at gmail.com
Tue Feb 24 14:28:20 MSK 2009


Wiadomość napisana w dniu 2009-02-24, o godz. 11:02, przez Igor Sysoev:

> On Wed, Feb 18, 2009 at 07:39:41PM +0200, Karolis 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.
>
>    location /dbfile {
>        rewrite  "^/dbfile/([0-9]{3})([0-9]{3})([0-9]{3})/(.*)$"
>                 /cache/$1/$2/$1$2$3__$4  last;
>    }
>
>    location /cache/ {
>        flv;
>        error_page  404  = @apache;
>    }
>
>    location @apache {
>        proxy_pass  http://127.0.0.1:8080;
>    }
>
> However, Apache should pass flv headers by itself.

Igor - is this possible to store flv file (not only from certain  
seeked point)  from "Apache" in cache (maybe using proxy_store) and  
also have flv seekeing working both with cached and proxied files?

Kamil






More information about the nginx mailing list