| title | description | primary_category | tags | integration_type | hosting_models | website_url | docs_url | publisher | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
HAProxy |
Ready-to-run HAProxy container template you can run directly or inherit to integrate a high-performance load balancer and proxy into your infrastructure. |
networking |
|
template |
|
monk.io |
This template provides a production‑ready HAProxy instance as a Monk runnable. You can:
- Run it directly to get a managed HAProxy load balancer with sensible defaults
- Inherit it in your own runnable to seamlessly add load balancing and high availability to your services
HAProxy is a free, very fast and reliable solution offering high availability, load balancing, and proxying for TCP and HTTP-based applications. It is particularly suited for high traffic web sites and can handle 100K+ concurrent connections.
- HAProxy container (
haproxyimage, configurable tag) - Network service on port 8080 (configurable)
- Custom HAProxy configuration file
- Backend server routing and health checking
- Connection timeouts and load balancing algorithms
- Load templates
monk load MANIFEST- Run HAProxy with defaults
monk run haproxy/haproxy- Customize backend servers (recommended via inheritance)
Running directly uses the defaults defined in this template's variables. To point HAProxy at your own backend servers:
- Preferred: inherit and override variables with your backend configuration as shown below.
- Alternative: fork/clone and edit the
variablesinhaproxy.yml, thenmonk load MANIFESTand run.
Once started, HAProxy will listen on port 8080 (or the configured host-port-number) and forward traffic to the configured backend servers.
Key variables you can customize in this template:
variables:
haproxy-image: "2.7.1" # container image tag
haproxy-port-number: 8080 # internal service port
host-port-number: 8080 # host-exposed port
backend-hostname: "1.1.1.1" # backend server address
backend-port: "443" # backend server portThe HAProxy configuration file (haproxy.cfg) is located in the files/ directory and can be customized before running. The template uses Monk's variable substitution ({{ v "variable-name" }}) to inject runtime configuration.
Inherit the HAProxy runnable in your application to add load balancing. Example:
namespace: myapp
loadbalancer:
defines: runnable
inherits: haproxy/haproxy
variables:
backend-hostname: <- connection-hostname("backend")
backend-port: "8080"
backend:
defines: runnable
containers:
app:
image: myorg/app
services:
api:
container: app
port: 8080
protocol: tcp
connections:
proxy:
runnable: loadbalancer
service: haproxyThen run your app group:
monk run myapp/backendFor multiple backends or advanced routing, customize the haproxy.cfg file to define multiple backend servers, health checks, and routing rules.
- Service:
haproxyon TCP port8080(configurable viahaproxy-port-number) - Host exposure: Port
8080(configurable viahost-port-number) - From other runnables in the same process group, use
connection-hostname("<connection-name>")to resolve the load balancer.
- Configuration file:
files/haproxy.cfg- mounted to/usr/local/etc/haproxy/haproxy.cfgin the container - The configuration supports Monk variable interpolation for dynamic backend configuration
- No persistent data storage required (HAProxy is stateless)
- Layer 4 (TCP) and Layer 7 (HTTP) load balancing
- SSL/TLS termination
- Health checking with automatic failover
- Sticky sessions (session affinity)
- Advanced routing and URL rewriting
- ACL-based traffic rules
- High performance (100K+ concurrent connections)
- Built-in DNS resolution for dynamic backends
- See other templates in this repository for complementary services
- Combine with monitoring tools (
prometheus-grafana/) for observability - Use with application servers (
nginx/,apache/) for complete web stack - Integrate with your application stack as needed
- Check logs:
monk logs -l 500 -f haproxy/haproxy- If backend servers are not responding, verify the
backend-hostnameandbackend-portvalues match your backend configuration. - Ensure backend servers are reachable from the HAProxy container's network.
- For custom configurations, validate your
haproxy.cfgsyntax before running.