Writing an alias to a proxy with no buffering

Hi to everybody, beginner here.

I have a location in my nginx configuration file that connects to a unix
domain proxy to stream a real time video. What I would like is to make
other locations point to the stream. It seems that the right option for
this is the alias directive.

So, I have a configuration like this:

server {
listen 80;
server_name localhost;

location /stream {
proxy_buffering off;
proxy_pass http://unix:/tmp/demo_socket:/;
}

location /mjpeg {
alias /stream;
}

}

but, while the /stream location does the right thing, the /mjpeg
location seems to give back a 404:

~$ wget --server-response -qO- “http://192.168.1.88/mjpeg

HTTP/1.1 404 Not Found
Server: nginx/1.0.12
Date: Tue, 28 Feb 2012 17:07:30 GMT
Content-Type: text/html
Content-Length: 169
Connection: keep-alive

Do alias directives not work with the proxy module? If they don’t, how
could I accomplish this? (without redirecting, a lot of streaming
clients don’t support redirect.)

Thank you,
Cristiano.

On Tue, Feb 28, 2012 at 06:27:58PM +0100, Cristiano Belloni wrote:

Hi there,

I have a location in my nginx configuration file that connects to a unix
domain proxy to stream a real time video. What I would like is to make
other locations point to the stream. It seems that the right option for
this is the alias directive.

“alias” is for static files rather than for proxying.

location /stream {
proxy_buffering off;
proxy_pass http://unix:/tmp/demo_socket:/;
}

location /mjpeg {
alias /stream;
}

Does

location /mjpeg {
proxy_buffering off;
proxy_pass http://unix:/tmp/demo_socket:/;
}

do what you want?

f

Francis D. [email protected]

On 02/28/2012 07:29 PM, Francis D. wrote:

location /mjpeg {
proxy_buffering off;
proxy_passhttp://unix:/tmp/demo_socket:/;
}
It works, thank you. Can I ask how to translate location /stream0 to
/stream?s=0

On Wed, Feb 29, 2012 at 12:13:14PM +0100, Cristiano Belloni wrote:

On 02/28/2012 07:29 PM, Francis D. wrote:

Hi there,

It works, thank you. Can I ask how to translate location /stream0 to
/stream?s=0

If you mean “the client asks nginx for /stream0 and nginx asks the
proxy_pass host for /stream?s=0”, then

location = /stream0 {
proxy_buffering off;
proxy_pass http://unix:/tmp/demo_socket:/stream?s=0;
}

should work. (But you may see odd things if the client asks for
/stream0?query=string.)

I suspect that you will be better served by advertising the urls that
the proxy_pass host recognises, if that is possible.

Good luck with it,

f

Francis D. [email protected]