HAProxy Configuration Guide
This guide provides detailed instructions for configuring HAProxy to expose both the Runtime API and the Statistics page, which are required for the HAProxy MCP Server to function properly.
Table of Contents
Runtime API Configuration
HAProxy's Runtime API allows for dynamic configuration changes and monitoring without restarting the service. The HAProxy MCP Server requires access to this API to function properly.
TCP Socket Mode
To expose the Runtime API over a TCP socket, add the following to your haproxy.cfg:
global
# Other global settings...
# Runtime API configuration
stats socket [email protected]:9999 level admin
# OR for more secure setup, bind to localhost only
# stats socket [email protected]:9999 level adminFor HAProxy 2.0 and later, you can also use:
Unix Socket Mode
For Unix socket mode, which provides better security as it's file-system based:
Ensure that the directory exists and has proper permissions:
Statistics Page Configuration
HAProxy's Statistics page provides a web-based dashboard for monitoring. To enable it, add:
For a more secure setup, restrict access:
Security Considerations
When exposing the Runtime API and Statistics page, consider these security practices:
Authentication: Always use authentication for production environments
Binding: Bind services to localhost or internal IPs only when possible
Firewall Rules: Use firewall rules to restrict access to the Runtime API and Stats ports
TLS/SSL: For statistics page, consider using HTTPS:
Access Control: Limit who can access admin functions:
Combined Configuration Example
Here's a complete example that includes both Runtime API and Statistics page:
Troubleshooting
If you experience issues connecting to the Runtime API or Statistics page:
Check permissions:
For Unix sockets:
ls -la /var/run/haproxy/admin.sockEnsure the user running the MCP server has access
Verify the socket is listening:
For TCP mode:
netstat -an | grep 9999For Stats page:
netstat -an | grep 8404
Test connections directly:
Check HAProxy logs:
Restart HAProxy after config changes:
For more detailed information, refer to the official HAProxy documentation.
Last updated
Was this helpful?