flv streaming and proxy_pass

Karolis karolis at pg.lt
Wed Feb 18 20:39:41 MSK 2009

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) {

    # 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?


More information about the nginx mailing list