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.

2 Answers 2


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

  • hmmm when I do this and begin refreshing the page, I end up getting a 503 within a minute or so Commented May 23, 2017 at 10:21
  • i had to have multiple duplicate "server" lines discourse.haproxy.org/t/…
    – jamshid
    Commented Jul 31, 2018 at 3:19

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
    Commented Apr 7, 2015 at 15:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .