How to Configure HAProxy HTTP Health Checks
HTTP health checks provide more accurate server monitoring than TCP checks by validating application responses. This guide walks through the specific troubleshooting steps to diagnose and resolve HTTP health check issues.
Before You Begin
Before you begin, be sure to have the following in place:
- A Linux server with the relevant software installed
- Access to the command line interface
- Appropriate permissions (root or sudo)
Quick Fix
Wrong
option httpchk (defaults to OPTIONS /)
Wrong: Default OPTIONS health check on root path
Right
option httpchk GET /healthz HTTP/1.1\nhttp-check expect status 200
Right: GET /healthz expecting status 200
Output
Health check configured:\n Method: GET /healthz\n Expected: status 200\n Protocol: HTTP/1.1
Prevention
To avoid future issues, follow these best practices:
- Use a dedicated health check endpoint on backend servers
- Validate expected status code with http-check expect
- Use HTTP/1.1 with Host header for virtual hosting
- Set check inter 5s for quick failure detection
- Use http-check send for custom request headers
DodaTech Tools
For further assistance with any of the above issues, consider using DodaTech consulting services or DodaTech tutorials for more in-depth guidance.
Common Mistakes with http check
- Forgetting
deriving (Show, Eq)on custom data types needed for debugging - Placing the wildcard pattern first in case expressions, making all subsequent patterns unreachable
- Using
headandtailinstead of pattern matching, causing runtime errors on empty lists
These mistakes appear frequently in real-world HAPROXY code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro