Layer 7 (HAProxy)

Overview of the LB Layer7 tab

On this page

This page applies to:

  • HAProxy ALOHA - all versions

The LB Layer7 tab embeds HAProxy, which is a reverse proxy for load balancing TCP and HTTP. As a reverse proxy, it terminates the client’s connection on one end, then opens a connection to the server on the other end. You enable TCP mode or HTTP mode by setting the mode directive in the configured frontend and backend sections.

  • In HTTP mode, you can make routing decisions based on HTTP metadata such as the URL path, HTTP headers, and cookies. Set mode http.
  • In TCP mode, you can load balance TCP traffic, over which you can transport any TCP-compatible application including HTTP, SMTP, POP, IMAP, and MySQL. Set mode tcp.
  • HAProxy ALOHA 17.0 and newer: Load balance UDP by adding a udp-lb configuration section.

The LB Layer7 tab supports a variety of configurable options, including:

  • Load balancing schemes including round robin, least connection, source, destination, source/destination, URI, HTTP header values, and others.
  • Server health checks by HTTP or TCP protocol.
  • Traffic rate limiting and traffic policing.
  • Rich conditional switching rules (ACLs) for traffic filtering and control.
  • Rich SSL and security stack.
  • Web Application Firewall (WAF).
  • Rich observability support.

HAProxy is a good choice for many use cases, while the embedded LVS load balancer is good for others.

Prefer LVS (LB Layer4 tab) when Prefer HAProxy (LB Layer7 tab) when
  • You want to enable Direct Server Return from backend servers.
  • You want to enable destination NAT. If you also need source NAT, use the NAT tab to configure it.
  • You want to load balance an application that uses TCP or UDP (HTTP, WebSocket, FastCGI, Syslog, DNS, for example) with superior logging and statistics.
  • Your use case requires TLS, HTTP routing rules, HTTP header modification, rate limiting, caching, compression, or other HAProxy features.

See also Jump to heading

Do you have any suggestions on how we can improve the content of this page?