# When front proxy meet reverse proxy

**URL:** <https://www.ruby-forum.com/t/when-front-proxy-meet-reverse-proxy/218300>\
**Category:** NGINX\
**Created:** [March 27, 2012, 1:44pm UTC](https://www.ruby-forum.com/t/when-front-proxy-meet-reverse-proxy/218300 "2012-03-27T13:44:48Z")\
**Posts on this page:** 6\
**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:** [March 27, 2012, 1:44pm UTC](https://www.ruby-forum.com/t/when-front-proxy-meet-reverse-proxy/218300/1 "2012-03-27T13:44:48Z")

</div>

Hi:

This is a cross post at  
stackoverflow[http://stackoverflow.com/questions/9872873/when-front-proxy-meet-reverse-proxy](http://stackoverflow.com/questions/9872873/when-front-proxy-meet-reverse-proxy),since  
I got no answser there,so I post it here.

Since I think my question is related to the reverse proxy.

This is the post body:

In our app,we have make the cross domain ajax request,and we have no  
control on the server domain which does not support jsonp,so we try to  
use  
the proxy.

We have a proxy.ashx on our server,and try to get the data through this  
proxy.

So in this case I think our server is the front server to the  
client,isn’t  
it?

However our server is deployed in the internal network which use the  
reverse proxy.

Say I make a requset:

[http://ourserver/proxy.ashx?url=http://crossdomainserver&para=xxx](http://ourserver/proxy.ashx?url=http://crossdomainserver&para=xxx).

Then the reverse proxy forward this requst to our server,but our server  
have no access to the internet,that’s to say,our server can not access  
[http://crossdomainserver](http://crossdomainserver) here.

So I want to know if you guys have met the same suitation,and how to  
solve  
it?

---

<div class="post-metadata">

**Author:** ![maven\_apache](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@maven\_apache](https://www.ruby-forum.com/u/maven_apache)\
**Post date:** [March 27, 2012, 10:18pm UTC](https://www.ruby-forum.com/t/when-front-proxy-meet-reverse-proxy/218300/2 "2012-03-27T22:18:08Z")

</div>

On Tue, Mar 27, 2012 at 07:43:22PM +0800, maven apache wrote:

Hi there,

I don’t understand your intended data flow.

Can you describe it more explicitly?

In general terms, “something” makes a http request to nginx; that  
“something” is “the client”. nginx is configured to proxy\_pass a request  
related to the original one to a back-end server; that back-end server  
is  
“upstream”.

client talks to nginx, and gets a response from nginx. The client  
doesn’t  
know or care about upstream.

nginx talks to upstream and gets a response from upstream. nginx doesn’t  
know or care how upstream generates the response.

If a web browser is configured to use a proxy server, then as far as  
nginx  
is concerned, that proxy server is “the client”, not the web browser.

From your description, it sounds like “some javascript running in the  
browser” is “the client”.

It’s not clear (to me) what is “nginx” and what is “upstream”.

If you can explain more, it might help others to answer your question.

## f

Francis D. removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![maven\_apache](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@maven\_apache](https://www.ruby-forum.com/u/maven_apache)\
**Post date:** [March 28, 2012, 1:17pm UTC](https://www.ruby-forum.com/t/when-front-proxy-meet-reverse-proxy/218300/3 "2012-03-28T13:17:42Z")

</div>

Since I am not good at English,so I make a picture in the attach,hope  
you  
can get it.

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

---

<div class="post-metadata">

**Author:** ![maven\_apache](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@maven\_apache](https://www.ruby-forum.com/u/maven_apache)\
**Post date:** [March 28, 2012, 4:08pm UTC](https://www.ruby-forum.com/t/when-front-proxy-meet-reverse-proxy/218300/4 "2012-03-28T16:08:05Z")

</div>

Hi…

I saw the picture but don’t see any problem for nginx there, your  
problem in that picture seems to be that you want your backend to  
access crossdomain server but your backend do not have internet acces.

If that’s the case, and you don’t need to support thousands of cross  
domains, you can configure Nginx to be reverse proxy of cross domain  
server and use it to access internet from your backend, so when the  
backends want to access crossdomain, it does so through nginx and  
nginx indeed have internet access.

One good thing of doing this is that if you are already parsing with  
any tool your logs, you will have nice stats of your crossdomain  
servers behaviors (eg: backend generation time, etc)

Or maybe I got it all wrong, in that case, please discard this message  
🙂

On Wed, Mar 28, 2012 at 8:16 AM, maven apache [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > I don’t understand your intended data flow.
> 
> * * *
> 
> 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)

–  
Guzmn B. Nez  
Senior Perl Developer / Sysadmin  
Web: [http://guzman.braso.info](http://guzman.braso.info)  
Mobile: +598 98 674020

---

<div class="post-metadata">

**Author:** ![maven\_apache](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@maven\_apache](https://www.ruby-forum.com/u/maven_apache)\
**Post date:** [March 28, 2012, 6:02pm UTC](https://www.ruby-forum.com/t/when-front-proxy-meet-reverse-proxy/218300/5 "2012-03-28T18:02:52Z")

</div>

On 28 March 2012 15:27, maven apache [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > backends want to access crossdomain, it does so through nginx and  
> > nginx indeed have internet access.
> 
> Can you explain more about use the nginx be the reverse proxy of the cross  
> domain?

You need to tell nginx it should accept requests for the different  
cross-domain FQDNs you’re using, and proxy\_pass them in nginx as  
appropriate.

Then arrange for your app to make its requests to nginx, not the  
unreachable cross-domain server.  
You may need to hosts-file the FQDNs on your app server if you can’t  
change the app and make it separate its understanding of the HTTP Host  
header (“[cross.domain.whatever.com](http://cross.domain.whatever.com)”) from the actual IP it should talk  
(nginx).

It’s a pretty simple setup.  
We _could_ write the nginx config to do this for you, but we’d be  
depriving you of the excellent learning experience you’ll get doing it  
yourself 😉

Have fun!

Jonathan

---

<div class="post-metadata">

**Author:** ![maven\_apache](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@maven\_apache](https://www.ruby-forum.com/u/maven_apache)\
**Post date:** [March 28, 2012, 4:28pm UTC](https://www.ruby-forum.com/t/when-front-proxy-meet-reverse-proxy/218300/6 "2012-03-28T16:28:36Z")

</div>

2012/3/28 Guzmn B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> Hi…
> 
> I saw the picture but don’t see any problem for nginx there, your  
> problem in that picture seems to be that you want your backend to  
> access crossdomain server but your backend do not have internet acces.

Yes,this is what I want.

> If that’s the case, and you don’t need to support thousands of cross  
> domains, you can configure Nginx to be reverse proxy of cross domain  
> server and use it to access internet from your backend, so when the  
> backends want to access crossdomain, it does so through nginx and  
> nginx indeed have internet access.

Can you explain more about use the nginx be the reverse proxy of the  
cross  
domain?
