Passing response from upstream server to another upstream server

Jeff Kaufman jefftk at google.com
Wed Nov 13 18:21:11 UTC 2013


I think Arnaud is suggesting that instead of a request flow like:

1. nginx[A] receives request, forwards to upstream[B]
2. upstream[B] creates response and replies to nginx[A]
3. nginx[A] forwards response to upstream[C]
4. upstream[C] modifies response and replies to nginx[A]
5. nginx[A] returns response to user

You instead consider:

1. nginx[A] receives request, forwards to upstream[C]
2. upstream[C] forwards to upstream[B]
3. upstream[B] creates response and replies to upstream[C]
4. upstream[C] modifies request as it passes through and replies to nginx[A]
5. nginx[A] returns response to user

Much more software is written expecting flows like this second one.



On Wed, Nov 13, 2013 at 11:30 AM, MAGNIEN, Thierry
<thierry.magnien at sfr.com> wrote:
> Hi Arnaud,
>
> Thanks for your response but my goal is to have only one Nginx server, not chaining them.
>
> From what I've seen, I think I should be able to achieve this using proxy + lua module, and I'll write my own module using subrequests if performance is too low.
>
> Regards,
> Thierry
>
> -----Message d'origine-----
> De : Arnaud GRANAL [mailto:serphen at gmail.com]
> Envoyé : mercredi 13 novembre 2013 17:24
> À : nginx-devel at nginx.org
> Cc : MAGNIEN, Thierry
> Objet : Re: Passing response from upstream server to another upstream server
>
> Hi Thierry,
>
> This is the nginx-devel mailing-list (for development and commits), I
> guess you will have better luck on nginx user list
> http://mailman.nginx.org/mailman/listinfo/nginx
>
> nginx can be an upstream of another nginx (as reverse proxy).
> This means that you can chain nginx [A]->nginx [B]->nginx [C]->nginx
> [D] as much as you want. However the more layers you add, the more
> risks you have to break the chain (in reality, you end up with tons of
> opened sockets, issues with TIME_WAIT, tuning persistent connections
> between instances, etc..).
>
> Whenever possible, try to keep nginx [A] -> nginx [D] because this
> makes debugging and monitoring very simple.
> If you are trying to reach an internal network, you can for example
> use a GRE tunnel if your problem is that [A] can't talk directly with
> [D].
>
> Arnaud.
>
> On Tue, Nov 12, 2013 at 4:04 PM, MAGNIEN, Thierry
> <thierry.magnien at sfr.com> wrote:
>> Hi,
>>
>> I would like to achieve something like this:
>> - Nginx receives request from client
>> - Nginx forwards request to an upstream server and reads response
>> - Nginx sends this  response to another upstream server (it will perform some content modification)
>> - Nginx gets final response and sends it over to client
>>
>> Is there a way to achieve this by using existing modules and an adequate configuration, or do I need to write my own "double upstream" module ?
>>
>> Thanks a lot,
>> Thierry
>>
>> _______________________________________________
>> nginx-devel mailing list
>> nginx-devel at nginx.org
>> http://mailman.nginx.org/mailman/listinfo/nginx-devel
>
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel



More information about the nginx-devel mailing list