Notes on HAProxy Configuration


The primary objective of a load balancer is:

  • acting as a reverse proxy (exposing an IP and hiding server implementation behind a backend IP).
  • Load balancing and higher availability with multiple backend servers
  • Request queuing

The most four basic sections of an HAProxy configuration are:

  • Default
  • Frontend
  • Backend
  • Global

All the sections are similar to Nginx config. The interesting thing is layer 4 or layer 7 routing of requests to backend servers. Layer 4 is TCP based and layer 7 is the application layer, based on HTTP. A health check with layer 4 is a successful TCP connection of HAProxy with a backend server. A layer 7 health check is a successful response of an HTTP API (HEAD/GET). The latter is slower but smarter.

HAProxy Logs & Config
  • /var/log/haproxy.log
  • /etc/haproxy/haproxy.cfg