LinuxCommandLibrary

haproxy

high-performance TCP/HTTP load balancer and proxy

TLDR

Start HAProxy

$ haproxy -f [/etc/haproxy/haproxy.cfg]
copy
Check configuration
$ haproxy -c -f [/etc/haproxy/haproxy.cfg]
copy
Reload configuration
$ haproxy -f [config.cfg] -sf $(pidof haproxy)
copy
Start in daemon mode
$ haproxy -D -f [config.cfg]
copy
Show version
$ haproxy -v
copy

SYNOPSIS

haproxy [options] -f config

DESCRIPTION

HAProxy (High Availability Proxy) is a high-performance TCP/HTTP load balancer and reverse proxy that distributes incoming traffic across pools of backend servers. Its configuration is organized around frontends (which accept client connections on bound addresses and ports) and backends (which define the set of servers that handle requests, along with the balancing algorithm -- round-robin, least-connections, source-hash, and others). Active health checks continuously probe backend servers and automatically remove unhealthy nodes from rotation.
Beyond basic load balancing, HAProxy provides SSL/TLS termination, HTTP header manipulation, content-based routing via ACLs, connection rate limiting, stick tables for session persistence, and a real-time statistics dashboard. It operates in an event-driven, single-process architecture that can handle hundreds of thousands of concurrent connections with low latency and minimal resource consumption, making it a standard choice for high-traffic production environments.

PARAMETERS

-f file

Configuration file.
-c
Check configuration and exit.
-D
Daemon mode.
-sf pids
Soft-stop old processes.
-st pids
Hard-stop old processes.
-p pidfile
PID file path.
-n maxconn
Maximum connections.
-N maxconn
Default per-proxy maxconn.
-d
Debug mode.
-V
Verbose mode.

CONFIG EXAMPLE

$ frontend http_front
    bind *:80
    default_backend http_back

backend http_back
    balance roundrobin
    server web1 192.168.1.1:80 check
    server web2 192.168.1.2:80 check
copy

CAVEATS

Configuration changes require reload. Complex ACLs need careful testing. Statistics require separate configuration. SSL setup needs certificate management.

HISTORY

HAProxy was created by Willy Tarreau in 2000 and has become one of the most widely deployed load balancers. It powers high-traffic sites including GitHub, Reddit, and Stack Overflow.

SEE ALSO

nginx(1), envoy(1), traefik(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community