Summary
To send health check probes to a port other than the one to which normal traffic is sent, add the port argument. In the following example, the health check is sent to port 8080.
backend servers server srv1 10.0.0.1:80 check port 8080 server srv2 10.0.0.2:80 check port 8080
Use case
Sometimes the main application service (port 80/443) is only healthy if other internal components are also up. Running a dedicated health check endpoint on a different port (e.g., 8080) ensures HAProxy LB probes check application readiness, not just whether TCP/HTTP accepts connections.
Example Use Case:
Imagine a web application with the following design:
Port 80 (frontend): Handles user HTTP requests.
Port 8080 (health check endpoint): Exposes /healthz or /ready for monitoring.
It only returns 200 OK if the database and cache are reachable and the app is fully initialized.
If the DB or cache goes down, /healthz returns 500, but port 80 might still respond (with errors).
Additional information
Consider the CLI option:
set load-balancing haproxy backend bk01 server srv01 check-port xxx
or
set load-balancing haproxy backend bk01 server srv01 check port xxx