Welcome! Log In Create A New Profile

Advanced

Re: Setting a custom header on a proxied request

Maxim Dounin
October 14, 2015 01:10PM
Hello!

On Wed, Oct 14, 2015 at 04:56:35PM +0000, Maxime Henrion wrote:

> Hello Maxim!
>
> Thank you again for your answer.
>
> I have read more about the upstream code as well as the the
> proxy module code, and now realize that headers are being
> serialized into a buffer a chain within the create_request
> callback, and that peer selection can happen after that.
>
> I cannot however use proxy_set_header in this particular case,
> as I have no variable to use that would expand to the desired
> value (the actual IP address of the peer currently being
> contacted). To the best of my knowledge, the $upstream_addr
> variable is closest to what I need, except that it contains all
> the upstream addresses that were contacted during request
> processing.
>
> Would you have any idea on how best to approach this problem? I
> was considering implementing a full-blown upstream module, but I
> have no evidence that the way the ngx_http_upstream.c code works
> is compatible with a scheme where headers would potentially need
> to be changed each time we select a new peer.

What you are trying to do is not something easily doable with
nginx upstream module. It's designed to reuse the same request
while connecting to multiple upstream servers from an upstream{}
block, and it considers all upstream servers in a block to be
identical - much like it happens when you are using a DNS name
with multiple A records.

If you want requests to different servers be different, I would
rather recommend using different upstream blocks and balancing
requests between them using some external means - e.g., by using
different locations or by using a proxy_pass with a variable.

--
Maxim Dounin
http://nginx.org/

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Setting a custom header on a proxied request

Maxime Henrion 588 October 12, 2015 10:14AM

Re: Setting a custom header on a proxied request

Andrew Hutchings 231 October 12, 2015 12:06PM

RE: Setting a custom header on a proxied request

Maxime Henrion 275 October 12, 2015 01:06PM

Re: Setting a custom header on a proxied request

Sorin Manole 271 October 12, 2015 02:08PM

Re: Setting a custom header on a proxied request

Maxim Dounin 195 October 14, 2015 12:36PM

RE: Setting a custom header on a proxied request

Maxime Henrion 211 October 14, 2015 12:14PM

Re: Setting a custom header on a proxied request

Maxim Dounin 219 October 14, 2015 12:34PM

RE: Setting a custom header on a proxied request

Maxime Henrion 250 October 14, 2015 12:58PM

Re: Setting a custom header on a proxied request

Maxim Dounin 242 October 14, 2015 01:10PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 266
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready