12

I have haproxy 1.5.8, it proxies some requests (based on the path) to a third-party we have no control over.

Since the IP of backend server is resolved once at startup, it breaks if the IP change.

If there a workaround for that ? In nginx it's possible to declare an internal variable and have it cached for X seconds. I didn't found a similar solution for HAProxy.

23

With the recent release of HAProxy 1.6 there is a solution to your problem. You can now define resolvers and associate these to your backend. IP resolution will then be done at runtime.

resolvers dns
  nameserver public-0  xx.xx.xx.xx:53
  hold valid 1s

frontend http
  bind *:8000
  default_backend site-backend

backend site-backend
  balance leastconn
  server site sub.example.com:80 resolvers dns check inter 1000

StackOverflow discussing this

Link to the corresponding documentation

1

Unfortunately, it seems like this is still a work in progress.

Have you considered using a separate nginx proxy? So that you forward requests for that backend to an nginx instance, which then does DNS resolution and forwards the request? Not ideak, but may work in a lower traffic environment.

  • There's always that solution, but hoping to find a solution that would keep it simple. – Bastien974 Apr 7 '15 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.