Description
Hi,
I'm using https://github.com/ledgetech/lua-resty-http for sending HTTP requests during request handling in NGINX. I'm sending a request to an upstream endpoint that resolves to 2 IPs, one ipv4 and one ipv6. However, due to the network topology where this is deployed, ipv4 addresses are not reachable from my instance.
The problem is that randomly some request fail to connect, and it appears that the ones that fail are those using the ipv4 address of the upstream endpoint.
I think the root cause of the issue is this:
https://github.com/openresty/lua-nginx-module?tab=readme-ov-file#tcpsockconnect
If the nameserver returns multiple IP addresses for the host name, this method will pick up one randomly.
Is it possible, and if so how, to make the socket prefer ipv6 IP addresses instead of randomly choosing one? Ideally it should transparently work this way but it has not been the case during my testing.
If this is not possible, is there any suggested way to make two concurrent requests and return whichever resolves first? Or customise the resolver configuration for the socket?
I have implemented a workaround by just completely disabling ipv4 resolution but obviously this is not ideal