# Reverse proxying video streaming

**URL:** <https://www.ruby-forum.com/t/reverse-proxying-video-streaming/205693>\
**Category:** NGINX\
**Created:** [April 13, 2011, 12:43pm UTC](https://www.ruby-forum.com/t/reverse-proxying-video-streaming/205693 "2011-04-13T12:43:24Z")\
**Posts on this page:** 5\
**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:** [April 13, 2011, 12:43pm UTC](https://www.ruby-forum.com/t/reverse-proxying-video-streaming/205693/1 "2011-04-13T12:43:24Z")

</div>

hi,

i’ve successfully reverse proxying streaming content through nginx.

this is my config

```
     location /stream/ {
         proxy_pass http://xxx.xxx.xxx.xxx:8080/stream.flv;
         proxy_redirect off;

         proxy_set_header Host $host;
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header X-Forwarded-For 

```

$proxy\_add\_x\_forwarded\_for;  
}

open via browser [http://www.example.com/stream/](http://www.example.com/stream/) success,without  
problem.

however, i need to append fake uri such as  
[http://www.example.com/stream/stream/content.flv](http://www.example.com/stream/stream/content.flv)

here’s what i’ve done so far

```
     location /stream/content.flv {
         proxy_pass http://xxx.xxx.xxx.xxx:8080/stream.flv;
         proxy_redirect off;

         proxy_set_header Host $host;
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header X-Forwarded-For 

```

$proxy\_add\_x\_forwarded\_for;  
}

it’s always pointed to /var/www/html/stream/content.flv

[error] 24546#0: \*1 open() “/var/www/html/stream/content.flv” failed (2:  
No such file or directory)

any clues?

thanks

Powered By [http://www.3g-net.net](http://www.3g-net.net)

---

<div class="post-metadata">

**Author:** ![Hari\_Hendaryanto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/57b2e6/32.png) [@Hari\_Hendaryanto](https://www.ruby-forum.com/u/Hari_Hendaryanto)\
**Post date:** [April 13, 2011, 1:31pm UTC](https://www.ruby-forum.com/t/reverse-proxying-video-streaming/205693/2 "2011-04-13T13:31:38Z")

</div>

On Wed, Apr 13, 2011 at 05:38:25PM +0700, Hari Hendaryanto wrote:

Hi there,

> i’ve successfully reverse proxying streaming content through nginx.

> ```
> location /stream/ {
> proxy_pass http://xxx.xxx.xxx.xxx:8080/stream.flv;
> 
> ```

> open via browser [http://www.example.com/stream/](http://www.example.com/stream/) success,without problem.

So: the browser asks nginx for /stream/, nginx asks the backend for  
/stream.flv, and things work happily.

> however, i need to append fake uri such as  
> [http://www.example.com/stream/stream/content.flv](http://www.example.com/stream/stream/content.flv)

The browser asks nginx for /stream/stream/content.flv. With  
the above configuration, nginx asks the backend for  
/stream.flvstream/content.flv. That doesn’t work for you.

So: what url do you want nginx to ask the backend for?

> here’s what i’ve done so far
> 
> ```
> location /stream/content.flv {
> 
> ```

This location doesn’t match your request, so won’t be used.

> any clues?

The debug log will show which location{} block is used for this request.

But before that: decide what you want nginx to ask the backend for,  
and see if [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/HttpProxyModule#proxy_pass) shows you  
how to achieve that.

Good luck with it,

## f

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

---

<div class="post-metadata">

**Author:** ![Hari\_Hendaryanto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/57b2e6/32.png) [@Hari\_Hendaryanto](https://www.ruby-forum.com/u/Hari_Hendaryanto)\
**Post date:** [April 13, 2011, 1:43pm UTC](https://www.ruby-forum.com/t/reverse-proxying-video-streaming/205693/3 "2011-04-13T13:43:59Z")

</div>

Hello!

On Wed, Apr 13, 2011 at 05:38:25PM +0700, Hari Hendaryanto wrote:

> ```
> proxy_set_header Host $host;
> 
> ```
> 
> [error] 24546#0: \*1 open() “/var/www/html/stream/content.flv” failed  
> (2: No such file or directory)
> 
> any clues?

Most likely you have some regexp location in your config which  
matches \*.flv.

If you need exact match - most obvious solution is to use exact  
match location instead, i.e.

```
location = /stream/content.flv {
    ...
}

```

Exact match locations are considered most specific and prevent  
testing of regexp locations. The same for normal static locations  
may be achieved via “^~” (no regexp) modifier.

Alternative aproach is to properly isolate regexp locations by  
nesting them into appropriate normal locations, i.e. do something  
like

```
location / {
    ...

    location ~ \.flv$ {
        ...
    }
}

location /stream/ {
    ...
}

```

This is actually recommended, but not exactly required in your  
case as it looks like you need exact match anyway.

Maxim D.

---

<div class="post-metadata">

**Author:** ![Hari\_Hendaryanto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/57b2e6/32.png) [@Hari\_Hendaryanto](https://www.ruby-forum.com/u/Hari_Hendaryanto)\
**Post date:** [April 13, 2011, 2:17pm UTC](https://www.ruby-forum.com/t/reverse-proxying-video-streaming/205693/4 "2011-04-13T14:17:26Z")

</div>

hi, francis, thanks for quick reply

On 4/13/2011 6:30 PM, Francis D. wrote:

> however, i need to append fake uri such as
> 
> > [http://www.example.com/stream/stream/content.flv](http://www.example.com/stream/stream/content.flv)  
> > The browser asks nginx for /stream/stream/content.flv. With  
> > the above configuration, nginx asks the backend for  
> > /stream.flvstream/content.flv. That doesn’t work for you.
> 
> So: what url do you want nginx to ask the backend for?

ok, sorry that was typo. it should be  
[http://www.example.com/stream/content.flv](http://www.example.com/stream/content.flv)

> > here’s what i’ve done so far
> > 
> > ```
> > location /stream/content.flv {
> > 
> > ```
> 
> This location doesn’t match your request, so won’t be used.
> 
> > any clues?  
> > The debug log will show which location{} block is used for this request.
> 
> But before that: decide what you want nginx to ask the backend for,  
> and see if [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/HttpProxyModule#proxy_pass) shows you  
> how to achieve that.  
> but i don’t want to pass anything to backend, just creating dummy uri  
> “/stream/content.flv” , so my browser embbeded flash player recognize  
> it.

but thanks anyway 🙂

> Good luck with it,
> 
> f

Powered By [http://www.3g-net.net](http://www.3g-net.net)

---

<div class="post-metadata">

**Author:** ![Hari\_Hendaryanto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/57b2e6/32.png) [@Hari\_Hendaryanto](https://www.ruby-forum.com/u/Hari_Hendaryanto)\
**Post date:** [April 13, 2011, 2:19pm UTC](https://www.ruby-forum.com/t/reverse-proxying-video-streaming/205693/5 "2011-04-13T14:19:55Z")

</div>

On 4/13/2011 6:43 PM, Maxim D. wrote:

> 

whoaa, you’re so great. it worked.  
thanks alot maxim 🙂

> case as it looks like you need exact match anyway.
> 
> Maxim D.
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)

Powered By [http://www.3g-net.net](http://www.3g-net.net)
