| name | configuring-load-balancers |
| description | Configure use when configuring load balancers including ALB, NLB, Nginx, and HAProxy. Trigger with phrases like "configure load balancer", "create ALB", "setup nginx load balancing", or "haproxy configuration". Generates production-ready configurations with health checks, SSL termination, sticky sessions, and traffic distribution rules.
|
| allowed-tools | Read, Write, Edit, Grep, Glob, Bash(aws:*), Bash(gcloud:*), Bash(nginx:*) |
| version | 1.28.0 |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| license | MIT |
| tags | ["devops","load-balancers"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
Configuring Load Balancers
Overview
Configure load balancers across AWS (ALB, NLB), GCP (HTTP(S) LB, TCP/UDP LB), Nginx, and HAProxy. Generate production-ready configurations with health checks, SSL/TLS termination, path-based and host-based routing, sticky sessions, rate limiting, and traffic distribution rules for high-availability deployments.
Prerequisites
- Backend servers identified with IPs, DNS names, and ports
- Load balancer type determined: L4 (NLB, HAProxy TCP) or L7 (ALB, Nginx, HAProxy HTTP)
- SSL/TLS certificates available (ACM, Let's Encrypt, or self-signed) if using HTTPS
- Health check endpoints defined on backend services (e.g.,
/health returning 200)
- Cloud provider CLI installed for managed load balancers (
aws, gcloud)
Instructions
- Select load balancer type based on requirements: ALB for HTTP/HTTPS with path routing, NLB for TCP/UDP with static IPs, Nginx for on-prem reverse proxy, HAProxy for high-performance TCP/HTTP
- Define the backend pool: list all backend server addresses, ports, and weights for weighted distribution
- Configure health checks with appropriate interval (10-30s), timeout (5s), healthy threshold (3), and unhealthy threshold (2)
- Set up SSL/TLS termination: configure certificates, redirect HTTP to HTTPS, set minimum TLS version to 1.2
- Define routing rules: path-based routing (
/api -> API pool, /static -> CDN), host-based routing (api.example.com -> API)
- Enable session persistence (sticky sessions) using cookies or source IP affinity where needed for stateful applications
- Add connection draining to gracefully handle backend removal during deployments
- Configure logging and monitoring: access logs to S3/CloudWatch, request metrics, error rate dashboards
- Test the configuration: validate syntax (
nginx -t, HAProxy config check), verify traffic distribution, and confirm failover behavior
Output
- Nginx configuration files (
nginx.conf, site configs) with upstream blocks and server directives
- HAProxy configuration (
haproxy.cfg) with frontend/backend sections
- Terraform HCL for AWS ALB/NLB with target groups, listeners, and rules
- GCP load balancer Terraform with backend services, URL maps, and health checks
- SSL certificate configuration and renewal automation
Error Handling