flv streaming and proxy_pass

Cliff Wells cliff at develix.com
Mon Feb 23 21:31:00 MSK 2009


On Wed, 2009-02-18 at 19:39 +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; }

You have two locations that match.  It appears that Nginx takes the
first one.   I'd try something like:

location /cache {
    location ~ \.flv$ { flv; }
    error_page 404 = @apache;
}

location @apache {
    proxy_pass http://127.0.0.1:8080;
}


Untested and don't really have time to experiment for you, so YMMV.

Regards,
Cliff







More information about the nginx mailing list