I’m looking for a solution for dynamically changing IP addresses behind hostnames.
Actual use case is the RDS in an AWS environment which due to maintenance sometimes gets a new IP address.
Now, it seems the forwarding of traffic seems to recognize the new IP address without restarting the HAProxy service - the health checks are not.
It seems health checks are using the IP address the first time the service starts up and resolves the hostnames - and that is not quite good of a health check…
DNS works fine in our system, IP address is being updated, but still the health check is looking into the old IP address causing the entry to go down and never come up again.
Is it possible to set a reset for the health check to periodically resolve the hostname again?
Or is the solution to not use health checks at all for hostnames that have dynamic IPs?
Thanks for the help!
PS: It’s about TCP traffic only… Maybe thats important, idk.
We are using the DNS settings configured on the operating system where HAProxy is running.
No resolver config was needed for now - what is your suggestion?
Checked that section, it is even mentioning that use case, thank you for that.
But it doesn’t really help me further implementing continuous renewing of IP of hostnames.
I added the following to the config and still if I run my tests the server never comes back to UP again:
resolvers customdnssettings
resolve_retries 1800
timeout resolve 1s
timeout retry 1s
hold other 10s
hold refused 10s
hold nx 10s
hold timeout 10s
hold valid 10s
listen Test_1234
bind *:1234
server test.123456789.aws.net:1521 test.123456789.aws.net:1521 check resolvers customdnssettings inter 10s fall 3 rise 2
Test:
Have a target behind test.123456789.aws.net to be up and running. HAProxy stats page lights up green.
Make this server go down.
Stats page: Entry turns red.
Change the DNS entry to something available.
Waiting for the DNS of the OS to update - once ping comes back from correct new location look at the stats page:
Entry never comes back to green UP status ever…
telnet works fine from that server to the new IP & Port.
If I boot up the “old” server it goes again to green. Which means that it is only health checking against the first IP it got when starting the HAProxy service.
Also I’d recommend removing libc from it altogether, so that you don’t have to wait around to see if the resolver works or not, but if the haproxy resolver is not actually used or doesn’t actually work, then the configuration won’t work at all (as opposed to working for a bit due to startup resolution, but then fail to update):
In the end the following settings needed to be set to make it work:
default-server init-addr none
resolvers customdnssettings
nameserver dns1 10.1.2.3:53
resolve_retries 1800
timeout resolve 1s
timeout retry 1s
hold other 10s
hold refused 10s
hold nx 10s
hold timeout 10s
hold valid 10s
parse-resolv-conf did not work at all, although the same server is mentioned in the resolv.conf as nameserver (but without port 53). It needs to be explicitly mentioned in the HAProxy config itself.