[PATCH] Prefer address family matching to local address in resolver (ticket #1535)

Maxim Dounin mdounin at mdounin.ru
Wed Jan 19 16:22:09 UTC 2022


Hello!

On Wed, Jan 19, 2022 at 04:08:32PM +0100, Lukas Lihotzki via nginx-devel wrote:

> # HG changeset patch
> # User Lukas Lihotzki <lukas at lihotzki.de>
> # Date 1642576371 -3600
> #      Wed Jan 19 08:12:51 2022 +0100
> # Node ID f922980f06b1162ae933c99c03bef09cfc12582f
> # Parent  aeab41dfd2606dd36cabbf01f1472726e27e8aea
> Prefer address family matching to local address in resolver (ticket #1535).
> 
> Without this change, upstream connections fail randomly for dual-stack
> host names when specifying a proxy_bind address (ticket #1535).
> 
> This changeset adds two flags for avoiding resolving to either IPv4 or IPv6
> addresses. stream and http set these flags based on the proxy_bind address.
> Avoided addresses are still returned if there are none of the other family, so
> the same error message as before is produced when connecting is impossible.

Thank you for the patch.

Suggested change looks wrong to me though, as it only addresses a 
particular use case when the name is resolved dynamically at run 
time using resolver.  In particular, it won't address the exact 
configuration listed in ticket #1535.

If the goal is to only address dynamic resolution, a better idea 
might be to use "resolver ... ipv6=off;" configured explicitly.  
Or, if you want to use only IPv6 addresses instead, introduce a 
similar option to only resolve IPv4 addresses: as previously 
discussed in ticket #1330, it might be beneficial for IPv6-only 
hosts in other cases as well.

-- 
Maxim Dounin
http://mdounin.ru/



More information about the nginx-devel mailing list