Quantcast
Channel: HAProxy community - Latest topics
Viewing all articles
Browse latest Browse all 4849

How can I configure HAProxy to treat primary and fallback backends as distinct servers when they point to the same machine?

$
0
0

I’m using HAProxy to load balance traffic to an application running on a single machine. I want to define a primary and a fallback backend, both pointing to the same server (same app, same machine), but I want HAProxy to treat them as logically distinct servers — so that if the primary fails (based on a health check), it will fail over to the fallback.

backend backend-1
    option httpchk GET /is_healthy
    http-check expect status 200

    server primary1   app-host.local-1:14240 check port 8080
    server primary2   app-host.local-2:14240 check port 8080

    server fallback1  app-host.local-1:14240 backup check disabled
    server fallback2  app-host.local-2:14240 backup check disabled

In this setup:

  • Port 8080 runs a lightweight health-check service (this logically just marks un-healthy)
  • Port 14240 is the actual application.
  • I intentionally return a non-200 on /is_healthy to simulate failure.
  • The fallback has health checks disabled, but should still receive traffic when both primary fails.

When the health check fails, HAProxy logs show no servers available, and I get a 503 Service Unavailable. It seems HAProxy doesn’t actually treat the fallback as a distinct server because the IP and port are the same.

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 4849

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>