Set up load balancing configuration
✓Works with OpenClaudeYou are a DevOps engineer setting up load balancing infrastructure. The user wants to configure a load balancer to distribute traffic across multiple backend servers with health checks and session persistence.
What to check first
- Verify backend servers are running and accessible:
curl -I http://<backend-ip>:8080 - Check if you have HAProxy, Nginx, or cloud provider load balancer credentials configured
- Confirm firewall rules allow traffic on ports 80, 443, and backend service ports
- Run
sudo systemctl status haproxyorsudo systemctl status nginxto see if a load balancer is already installed
Steps
- Install HAProxy:
sudo apt-get install haproxy(Ubuntu/Debian) or use your package manager - Identify all backend server IPs and ports (e.g., 10.0.1.10:8080, 10.0.1.11:8080)
- Edit
/etc/haproxy/haproxy.cfgand define a frontend listening on port 80 - Create a backend section with multiple server entries and set the balancing algorithm (roundrobin, leastconn, or source)
- Configure health checks with
check inter 5000 rise 2 fall 3to monitor backend availability - Enable session persistence with
cookie SERVERID insert indirect nocacheif stateful requests are required - Set up logging by uncommenting
log /dev/log local0and restarting rsyslog - Validate configuration with
sudo haproxy -f /etc/haproxy/haproxy.cfg -c - Start HAProxy:
sudo systemctl restart haproxy - Test load balancing by making multiple requests:
for i in {1..10}; do curl http://localhost; done
Code
# /etc/haproxy/haproxy.cfg - Complete load balancer configuration
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
daemon
maxconn 4096
defaults
log global
mode http
option httplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
errorfile 400 /etc/haproxy/errors/400.http
errorfile 503 /etc/haproxy/errors/503.http
frontend http_front
bind *:80
bind *:443 ssl crt /etc/haproxy/certs/server.pem
default_backend http_back
option forwardfor
redirect scheme https code 301 if !{ ssl_fc }
backend http_back
balance roundrobin
cookie SERVERID insert indirect nocache
# Backend servers with health checks
server
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Networking Skills
Other Claude Code skills in the same category — free to download.
HTTP Client
Create configured HTTP client with interceptors
Retry Logic
Implement retry logic with exponential backoff
Circuit Breaker
Implement circuit breaker pattern
Request Queue
Queue and batch HTTP requests
Proxy Setup
Set up reverse proxy configuration
SSL Setup
Configure SSL/TLS certificates
DNS Setup
Configure DNS records
Nginx Reverse Proxy
Configure Nginx as reverse proxy with upstream servers
Want a Networking skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.