Welcome! Log In Create A New Profile

Advanced

Re: IPv6 & IPv4 backend with proxy_bind

November 26, 2013 11:39AM
Attached is the patch,

This is the first time I have created a variable or really done anything
inside the http request processing flow so feel free to let me know if
there is a better way to do something or if I have any edge cases.

This patch provides a $upstream_connecting variable which contains the IP
address and port of the upstream being connected. If there is no upstream,
it will return "-" my understanding is this may happen if the upstream is
DNS resolved (untested). There may be a better way of doing this?

This should be used in a config like the following -
map $upstream_connecting $test {
~^93\.184\.216\.119\: 192.168.2.40;
~^192\.168\.2\.([0-9]+)\: 192.168.2.40;
}

proxy_bind $test;

Regards,
Mathew



On Sat, Nov 23, 2013 at 12:10 AM, SplitIce <mat999@gmail.com> wrote:

> Ruslan, its funny you should mention this, I am testing a patch to do just
> that at the moment.
>
> Once I am certain that its not leaking memory and I have reviewed it in
> regards to the nginx code standards Ill post it in this email thread in
> case it is of use for others.
>
>
> On Fri, Nov 22, 2013 at 11:56 PM, Ruslan Ermilov <ru@nginx.com> wrote:
>
>> On Tue, Nov 19, 2013 at 09:09:34PM +1030, SplitIce wrote:
>> > An IPv6 based fallback is not the only solution we want to support,
>> > ultimately we would like to be able to load-balance between them as
>> well.
>> > An error_page based solution would not assist.
>> >
>> > I also get the feeling that such a hack would have large implications,
>> > while either an additional parameter or another directive would be a
>> simple
>> > & clean solution to a real identified deficiency.
>> >
>> > This kind of request is only going to get more common with the growing
>> > adoption of IPv6.
>>
>> You can make the currently selected peer address available as an nginx
>> variable, then use the "map" directive to compute the per-peer bind
>> address, like follows:
>>
>> map $peer_addr $bind_addr {
>> 192.168.1.100 192.168.1.1;
>> 2001:0db8::100 2001:0db8::1;
>> ...
>> }
>>
>> or like this:
>>
>> map $peer_addr $bind_addr {
>> ~: 2001:0db8::1;
>> default 192.168.1.1;
>> }
>>
>> Hint: the "proxy_bind" directive supports variables.
>>
>> _______________________________________________
>> nginx-devel mailing list
>> nginx-devel@nginx.org
>> http://mailman.nginx.org/mailman/listinfo/nginx-devel
>>
>
>
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

IPv6 & IPv4 backend with proxy_bind

splitice 1309 November 16, 2013 07:36AM

Re: IPv6 & IPv4 backend with proxy_bind

Maxim Dounin 583 November 18, 2013 06:48AM

Re: IPv6 & IPv4 backend with proxy_bind

splitice 2096 November 18, 2013 06:56AM

Re: IPv6 & IPv4 backend with proxy_bind

Maxim Dounin 591 November 18, 2013 08:28AM

Re: IPv6 & IPv4 backend with proxy_bind Attachments

splitice 778 November 26, 2013 11:39AM

Re: IPv6 & IPv4 backend with proxy_bind

Ruslan Ermilov 605 December 09, 2013 05:30AM

Re: IPv6 & IPv4 backend with proxy_bind Attachments

splitice 854 December 09, 2013 06:34AM

Re: IPv6 & IPv4 backend with proxy_bind

Ruslan Ermilov 616 December 09, 2013 07:16AM

Re: IPv6 & IPv4 backend with proxy_bind

splitice 908 November 26, 2013 11:39AM

Re: IPv6 & IPv4 backend with proxy_bind

splitice 826 November 26, 2013 11:39AM

Re: IPv6 & IPv4 backend with proxy_bind

Ruslan Ermilov 574 November 26, 2013 11:39AM



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

Online Users

Guests: 208
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