# Proxy with URI and params

**URL:** <https://www.ruby-forum.com/t/proxy-with-uri-and-params/215811>\
**Category:** NGINX\
**Created:** [January 16, 2012, 8:57pm UTC](https://www.ruby-forum.com/t/proxy-with-uri-and-params/215811 "2012-01-16T20:57:00Z")\
**Posts on this page:** 8\
**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:** [January 16, 2012, 8:57pm UTC](https://www.ruby-forum.com/t/proxy-with-uri-and-params/215811/1 "2012-01-16T20:57:00Z")

</div>

Hi,

I need to make a proxy solution. But I having some problems.

When the type [www.example.com/delivery/a/b/c](http://www.example.com/delivery/a/b/c) I need to make a proxy to  
[www.proxy.com/delivery/a/b/c/?var1=A&var2=B](http://www.proxy.com/delivery/a/b/c/?var1=A&var2=B)

So a did this configuration

location /delivery {  
subs\_filter [http://www.example.com/$uri](http://www.example.com/$uri)  
[http://www.proxy.com/$uri/?var1=A&var2=B](http://www.proxy.com/$uri/?var1=A&var2=B);  
proxy\_pass [http://www.proxy.com/$uri/?var1=A&var2=B](http://www.proxy.com/$uri/?var1=A&var2=B);  
}

Why it not working ?

Thanks and sorry for my English.

–  
Robson Roberto Souza Peixoto  
Robinho  
Master in Computer Science, University of Campinas  
Linux Counter #395633  
IRC: robsonpeixoto  
Twitter: [http://twitter.com/rrspba](http://twitter.com/rrspba)  
github: [https://github.com/robsonpeixoto](https://github.com/robsonpeixoto)

---

<div class="post-metadata">

**Author:** ![Robson\_Roberto\_Souz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b5a626/32.png) [@Robson\_Roberto\_Souz](https://www.ruby-forum.com/u/Robson_Roberto_Souz)\
**Post date:** [January 16, 2012, 9:06pm UTC](https://www.ruby-forum.com/t/proxy-with-uri-and-params/215811/2 "2012-01-16T21:06:57Z")

</div>

On 16 Jan 2012 19h56 WET, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> subs\_filter [http://www.example.com/$uri](http://www.example.com/$uri)  
> [http://www.proxy.com/$uri/?var1=A&var2=B](http://www.proxy.com/$uri/?var1=A&var2=B);  
> proxy\_pass [http://www.proxy.com/$uri/?var1=A&var2=B](http://www.proxy.com/$uri/?var1=A&var2=B);  
> }
> 
> Why it not working ?

Because the HTTPSubModule replaces something on the _request body_ not  
on the configuration.

I suppose you want something like this:

server {  
server\_name [www.example.com](http://www.example.com);

location /delivery {  
proxy\_pass [http://www.proxy.com$uri/?var1=A&var2=B](http://www.proxy.com$uri/?var1=A&var2=B);  
}  
}

$uri already starts with a ‘/’.

— appa

---

<div class="post-metadata">

**Author:** ![Robson\_Roberto\_Souz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b5a626/32.png) [@Robson\_Roberto\_Souz](https://www.ruby-forum.com/u/Robson_Roberto_Souz)\
**Post date:** [January 16, 2012, 10:56pm UTC](https://www.ruby-forum.com/t/proxy-with-uri-and-params/215811/3 "2012-01-16T22:56:01Z")

</div>

Thanks Antonio.

Now the problem is with the images, css and others thinks.  
When the site is loaded, it try to download from [www.example.com](http://www.example.com), and  
not  
from [www.proxy.com](http://www.proxy.com).

For example, the browser try to get the [www.example.com/menu.css](http://www.example.com/menu.css), but  
the  
correct is try to download the [www.proxy.com/menu.css](http://www.proxy.com/menu.css).

How to fix it?

Thanks

On Mon, Jan 16, 2012 at 6:06 PM, António P. P. Almeida  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> > 
> 
> $uri already starts with a ‘/’.
> 
> — appa
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)

–  
Robson Roberto Souza Peixoto  
Robinho  
Master in Computer Science, University of Campinas  
Linux Counter #395633  
IRC: robsonpeixoto  
Twitter: [http://twitter.com/rrspba](http://twitter.com/rrspba)  
github: [robsonpeixoto (Robson Roberto Souza Peixoto) · GitHub](https://github.com/robsonpeixoto)

---

<div class="post-metadata">

**Author:** ![Robson\_Roberto\_Souz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b5a626/32.png) [@Robson\_Roberto\_Souz](https://www.ruby-forum.com/u/Robson_Roberto_Souz)\
**Post date:** [January 17, 2012, 1:42am UTC](https://www.ruby-forum.com/t/proxy-with-uri-and-params/215811/4 "2012-01-17T01:42:31Z")

</div>

On 16 Jan 2012 21h54 WET, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> [1 \<multipart/alternative (7bit)\>]  
> [1.1 \<text/plain; UTF-8 (quoted-printable)\>]  
> Thanks Antonio.
> 
> Now the problem is with the images, css and others thinks. When the  
> site is loaded, it try to download from [www.example.com](http://www.example.com), and not  
> from [www.proxy.com](http://www.proxy.com).
> 
> For example, the browser try to get the [www.example.com/menu.css](http://www.example.com/menu.css),  
> but the correct is try to download the [www.proxy.com/menu.css](http://www.proxy.com/menu.css).

Then you need to be clear on what you want.

Perhaps you just and to proxy\_pass to another host. Or if you want to  
have other stuff like images and such try:

location /delivery {

```
location ~* /delivery/[^/]*.\(?:css|js|gif|jpe?g|png)$ {
    proxy_pass http://www.proxy.com;

}

proxy_pass http://www.proxy.com$uri/?var1=A&var2=B;

```

}

I’m just guessing. We could help you more if stated more clearly  
what’s your purpose.

— appa

---

<div class="post-metadata">

**Author:** ![Robson\_Roberto\_Souz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b5a626/32.png) [@Robson\_Roberto\_Souz](https://www.ruby-forum.com/u/Robson_Roberto_Souz)\
**Post date:** [January 17, 2012, 1:51pm UTC](https://www.ruby-forum.com/t/proxy-with-uri-and-params/215811/5 "2012-01-17T13:51:25Z")

</div>

On 17 Jan 2012 11h27 WET, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’d like to navigate on [http://www.proxy.com/delivery/.../.../.../](http://www.proxy.com/delivery/.../.../.../)  
> using my domain [http://www.example.com/](http://www.example.com/).
> 
> So the user will navigate on [www.example.com](http://www.example.com) and always show on URL  
> the ’ [www.example.com/delivery/../../](http://www.example.com/delivery/../../)..’
> 
> It’s is possible?

Yes. Add the proxy\_redirect directive:

proxy\_redirect [http://www.proxy.com/delivery/](http://www.proxy.com/delivery/) [http://www.example.com/](http://www.example.com/);

See: [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_redirect)

— appa

---

<div class="post-metadata">

**Author:** ![Robson\_Roberto\_Souz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b5a626/32.png) [@Robson\_Roberto\_Souz](https://www.ruby-forum.com/u/Robson_Roberto_Souz)\
**Post date:** [January 17, 2012, 12:28pm UTC](https://www.ruby-forum.com/t/proxy-with-uri-and-params/215811/6 "2012-01-17T12:28:23Z")

</div>

On Mon, Jan 16, 2012 at 11:04 PM, António P. P. Almeida  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> > > not from [www.proxy.com](http://www.proxy.com).
> > > 
> > > For example, the browser try to get the [www.example.com/menu.css](http://www.example.com/menu.css),  
> > > but the correct is try to download the [www.proxy.com/menu.css](http://www.proxy.com/menu.css).
> > 
> > Then you need to be clear on what you want.

I’d like to navigate on [http://www.proxy.com/delivery/.../.../.../](http://www.proxy.com/delivery/.../.../.../) using  
my  
domain [http://www.example.com/](http://www.example.com/).

So the user will navigate on [www.example.com](http://www.example.com) and always show on URL the  
’  
[www.example.com/delivery/../../](http://www.example.com/delivery/../../)..’

It’s is possible?

> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)

–  
Robson Roberto Souza Peixoto  
Robinho  
Master in Computer Science, University of Campinas  
Linux Counter #395633  
IRC: robsonpeixoto  
Twitter: [http://twitter.com/rrspba](http://twitter.com/rrspba)  
github: [robsonpeixoto (Robson Roberto Souza Peixoto) · GitHub](https://github.com/robsonpeixoto)

---

<div class="post-metadata">

**Author:** ![Robson\_Roberto\_Souz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b5a626/32.png) [@Robson\_Roberto\_Souz](https://www.ruby-forum.com/u/Robson_Roberto_Souz)\
**Post date:** [January 17, 2012, 2:05am UTC](https://www.ruby-forum.com/t/proxy-with-uri-and-params/215811/7 "2012-01-17T02:05:18Z")

</div>

On 17 Jan 2012 00h41 WET, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > For example, the browser try to get the [www.example.com/menu.css](http://www.example.com/menu.css),  
> > but the correct is try to download the [www.proxy.com/menu.css](http://www.proxy.com/menu.css).
> 
> Then you need to be clear on what you want.
> 
> Perhaps you just and to proxy\_pass to another host. Or if you want  
> to have other stuff like images and such try:
> 
> location /delivery {

- location ~\* /delivery/[^/]\*.(?:css|js|gif|jpe?g|png)$ {

- location ~\* /delivery/[^/]\*.(?:css|js|gif|jpe?g|png)$ {

— appa

---

<div class="post-metadata">

**Author:** ![Robson\_Roberto\_Souz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b5a626/32.png) [@Robson\_Roberto\_Souz](https://www.ruby-forum.com/u/Robson_Roberto_Souz)\
**Post date:** [January 18, 2012, 6:41pm UTC](https://www.ruby-forum.com/t/proxy-with-uri-and-params/215811/8 "2012-01-18T18:41:20Z")

</div>

Thanks for the tips. This solutions is a little slow, so  
I’m studding another way to solve it.

Thanks a lot.

On Tue, Jan 17, 2012 at 10:50 AM, António P. P. Almeida  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> Yes. Add the proxy\_redirect directive:  
> [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)

–  
Robson Roberto Souza Peixoto  
Robinho  
Master in Computer Science, University of Campinas  
Linux Counter #395633  
IRC: robsonpeixoto  
Twitter: [http://twitter.com/rrspba](http://twitter.com/rrspba)  
github: [robsonpeixoto (Robson Roberto Souza Peixoto) · GitHub](https://github.com/robsonpeixoto)
