load-balancer
Configures nginx load balancing with upstream servers, health checks, and failover strategies. Use when setting up load balancing, distributing traffic across multiple servers, or configuring upstream backends.
What this skill does
# Load Balancer Configuration
## Quick Start
Configure nginx to distribute traffic across multiple backend servers with health checks and automatic failover.
## Instructions
### Step 1: Define upstream block
Create an upstream block with your backend servers:
```nginx
upstream backend {
# Load balancing method (optional, defaults to round-robin)
least_conn; # or ip_hash, or omit for round-robin
# Backend servers
server backend1.example.com:8080 weight=3;
server backend2.example.com:8080 weight=2;
server backend3.example.com:8080;
# Backup server (used when all primary servers are down)
server backup.example.com:8080 backup;
# Health check parameters
keepalive 32;
}
```
### Step 2: Configure proxy in server block
Add proxy configuration to route traffic to the upstream:
```nginx
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://backend;
# Essential proxy headers
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Timeouts
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
# Buffering
proxy_buffering on;
proxy_buffer_size 4k;
proxy_buffers 8 4k;
}
}
```
### Step 3: Add health checks
Configure passive health checks (active checks require nginx Plus):
```nginx
upstream backend {
server backend1.example.com:8080 max_fails=3 fail_timeout=30s;
server backend2.example.com:8080 max_fails=3 fail_timeout=30s;
server backend3.example.com:8080 max_fails=3 fail_timeout=30s;
}
```
Parameters:
- `max_fails`: Number of failed attempts before marking server as unavailable
- `fail_timeout`: Time to wait before retrying a failed server
### Step 4: Test and reload
```bash
# Test configuration
nginx -t
# Reload nginx
nginx -s reload
```
## Load Balancing Methods
**Round-robin (default)**: Distributes requests evenly across servers
```nginx
upstream backend {
server backend1.example.com:8080;
server backend2.example.com:8080;
}
```
**Least connections**: Routes to server with fewest active connections
```nginx
upstream backend {
least_conn;
server backend1.example.com:8080;
server backend2.example.com:8080;
}
```
**IP hash**: Routes same client IP to same server (session persistence)
```nginx
upstream backend {
ip_hash;
server backend1.example.com:8080;
server backend2.example.com:8080;
}
```
**Weighted**: Distributes based on server capacity
```nginx
upstream backend {
server backend1.example.com:8080 weight=3; # Gets 3x traffic
server backend2.example.com:8080 weight=1;
}
```
## Common Patterns
### WebSocket proxying
```nginx
location /ws {
proxy_pass http://backend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
```
### Sticky sessions with cookie
```nginx
upstream backend {
server backend1.example.com:8080;
server backend2.example.com:8080;
# Requires nginx Plus or third-party module
sticky cookie srv_id expires=1h domain=.example.com path=/;
}
```
### Slow start (nginx Plus)
```nginx
upstream backend {
server backend1.example.com:8080 slow_start=30s;
server backend2.example.com:8080 slow_start=30s;
}
```
## Advanced
For detailed information, see:
- [Upstream Patterns](reference/upstream-patterns.md) - Advanced load balancing algorithms and patterns
- [Health Checks](reference/health-checks.md) - Comprehensive health check configuration
- [Caching](reference/caching.md) - Proxy caching strategies for load-balanced backends
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.