# Writing an alias to a proxy with no buffering

**URL:** <https://www.ruby-forum.com/t/writing-an-alias-to-a-proxy-with-no-buffering/217364>\
**Category:** NGINX\
**Created:** [February 28, 2012, 6:28pm UTC](https://www.ruby-forum.com/t/writing-an-alias-to-a-proxy-with-no-buffering/217364 "2012-02-28T18:28:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [February 28, 2012, 6:28pm UTC](https://www.ruby-forum.com/t/writing-an-alias-to-a-proxy-with-no-buffering/217364/1 "2012-02-28T18:28:46Z")

</div>

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](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://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.

---

<div class="post-metadata">

**Author:** ![Cristiano\_Belloni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e0b2c6/32.png) [@Cristiano\_Belloni](https://www.ruby-forum.com/u/Cristiano_Belloni)\
**Post date:** [February 28, 2012, 7:29pm UTC](https://www.ruby-forum.com/t/writing-an-alias-to-a-proxy-with-no-buffering/217364/2 "2012-02-28T19:29:28Z")

</div>

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](http://unix):/tmp/demo\_socket:/;  
> }
> 
> location /mjpeg {  
> alias /stream;  
> }

Does

location /mjpeg {  
proxy\_buffering off;  
proxy\_pass [http://unix](http://unix):/tmp/demo\_socket:/;  
}

do what you want?

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Cristiano\_Belloni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e0b2c6/32.png) [@Cristiano\_Belloni](https://www.ruby-forum.com/u/Cristiano_Belloni)\
**Post date:** [February 29, 2012, 12:14pm UTC](https://www.ruby-forum.com/t/writing-an-alias-to-a-proxy-with-no-buffering/217364/3 "2012-02-29T12:14:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Cristiano\_Belloni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e0b2c6/32.png) [@Cristiano\_Belloni](https://www.ruby-forum.com/u/Cristiano_Belloni)\
**Post date:** [February 29, 2012, 8:27pm UTC](https://www.ruby-forum.com/t/writing-an-alias-to-a-proxy-with-no-buffering/217364/4 "2012-02-29T20:27:25Z")

</div>

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](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. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
