17 messages in ru.sysoev.nginxRe: flv streaming and proxy_pass
FromSent OnAttachments
KarolisFeb 18, 2009 9:39 am 
Karolis DFeb 18, 2009 3:15 pm 
MaxFeb 18, 2009 4:01 pm 
Karolis DFeb 18, 2009 4:25 pm 
Karolis DFeb 19, 2009 1:07 pm 
Todd FisherFeb 19, 2009 1:53 pm 
KarolisFeb 19, 2009 2:11 pm 
Karolis DFeb 23, 2009 9:44 am 
Cliff WellsFeb 23, 2009 10:30 am 
Manlio PerilloFeb 23, 2009 10:39 am 
KarolisFeb 23, 2009 11:38 am 
Cliff WellsFeb 23, 2009 2:22 pm 
Igor SysoevFeb 24, 2009 2:01 am 
Kamil GorloFeb 24, 2009 3:27 am 
Michal FrackowiakFeb 24, 2009 11:45 am 
KarolisFeb 24, 2009 12:20 pm 
Tom HarrisJun 9, 2009 2:52 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: flv streaming and proxy_passActions...
From:Cliff Wells (cli@develix.com)
Date:Feb 23, 2009 10:30:37 am
List:ru.sysoev.nginx

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