configuring-load-balancers
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.
- License 许可
- MIT
- 最近更新
- 2026-03-20
- Stars
- ★ 4
- Forks
- 0
01 前言 Front Matter
- name
- configuring-load-balancers
- author
- Jeremy Longshore <jeremy@intentsolutions.io>
- license
- MIT
- version
- 1.0.0
- 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:*)
- compatible-with
- claude-code, codex, openclaw
02 资源文件 8
- 资产文件assets/haproxy_template.conf3.0 KB
- 资产文件assets/nginx_template.conf3.8 KB
- 资产文件assets/README.md232 B
- 参考文档references/errors.md754 B
- 参考文档references/examples.md176 B
- 参考文档references/README.md70 B
- 脚本scripts/generate_config.py3.6 KB
- 脚本scripts/README.md381 B
03 SKILL.md 正文
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.,
/healthreturning 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
| Error | Cause | Solution |
|---|---|---|
502 Bad Gateway |
Backend server unreachable or not responding | Verify backend IPs, ports, and firewall rules; check backend service health |
SSL certificate verify failed |
Certificate expired, wrong chain, or key mismatch | Verify certificate validity and chain with openssl s_client; regenerate if needed |
Target is unhealthy |
Health check endpoint returning non-200 or timing out | Verify health check path returns 200; increase timeout if backend is slow to respond |
nginx: configuration file test failed |
Syntax error in Nginx configuration | Run nginx -t to identify the specific error line; fix syntax and test again |
Session persistence not working |
Cookie-based stickiness misconfigured or client not sending cookies | Verify cookie name matches; use IP-based affinity as fallback for non-browser clients |
Examples
- "Configure an AWS ALB with HTTPS listener, path-based routing to two target groups (/api and /web), and health checks on /health."
- "Generate an Nginx reverse proxy config with upstream servers, sticky sessions via cookie, and rate limiting at 100 req/s per IP."
- "Create a HAProxy configuration for TCP load balancing across 4 database read replicas with health checks and connection draining."
Resources
- Nginx load balancing: https://nginx.org/en/docs/http/load_balancing.html
- HAProxy configuration: https://www.haproxy.org/download/2.8/doc/configuration.txt
- AWS ALB: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/
- GCP Load Balancing: https://cloud.google.com/load-balancing/docs
- See
${CLAUDE_SKILL_DIR}/references/errors.mdfor additional error handling patterns
04 同仓库更多 Skills
azure-apim-architecture
Analyzes and explains Azure API Management architecture decisions for enterprise API marketplace implementations using VNet Internal mode, Front Door, hybrid authentication, and multi-environment strategies. Use when discussing APIM component selection, network topology, cost optimization, or comparing alternatives like workspaces vs instances, VNet Internal vs External mode, or Front Door vs Application Gateway.
apiops-deployment
Guides deployment of Azure API Management infrastructure using Infrastructure as Code (Bicep/Terraform), CI/CD pipelines (GitHub Actions/Azure DevOps), and APIOps workflows. Use when deploying APIM, creating pipelines, or implementing dev→test→prod promotion strategies.
apim-policy-authoring
Creates production-ready Azure API Management policy XML for authentication (OAuth 2.0, JWT validation, subscription keys), rate limiting, CORS configuration, error handling, and API transformations. Use when implementing API security, access control, or request/response processing logic.
api-security-review
Reviews Azure API Management configurations for security vulnerabilities, OWASP API Security Top 10 compliance, VNet Internal mode validation, Private Link verification, and Azure Security Benchmark alignment. Use when performing security audits, pre-deployment validation, or compliance reviews.
jira-cli
Interact with Jira from the command line to create, list, view, edit, and transition issues, manage sprints and epics, and perform common Jira workflows. Use when the user asks about Jira tasks, tickets, issues, sprints, or needs to manage project work items.
calculator
Performs arbitrary-precision arithmetic calculations including addition, subtraction, multiplication, division, and exponents. Use when the user asks to calculate, compute, or evaluate math expressions, or when precise decimal arithmetic is needed to avoid floating-point errors.