Sessions reset after every refresh
Round-robin sends each request to a different upstream that doesn't share session state.
Fix: Switch to `ip_hash` or move sessions to a shared store (Redis) and stay on round-robin.
Search tools and pages.
Generate an nginx upstream + load balancer config with round-robin, least_conn, ip_hash, weights, health checks, and keepalive
sidebar • 160x600
Written by Giorgos Kostas. Last reviewed:
Nginx Load Balancer Config Generator emits an `upstream` block listing your backend servers, plus a server block that proxies to it with the load-balancing method that fits your traffic.
It supports the four built-in OSS Nginx methods: round-robin (default), `least_conn`, `ip_hash` (sticky by client IP), and consistent `hash $remote_addr`.
upstream name = backend servers = app1:3000, app2:3000, app3:3000 method = least_conn proxy_pass = http://backend
upstream backend {
least_conn;
server app1:3000;
server app2:3000;
server app3:3000;
}
server {
listen 80;
server_name api.example.com;
location / {
proxy_pass http://backend;
...
}
}Round-robin sends each request to a different upstream that doesn't share session state.
Fix: Switch to `ip_hash` or move sessions to a shared store (Redis) and stay on round-robin.
DNS round-robin or a stuck `keepalive` pool can pin Nginx to one server.
Fix: Set `keepalive 32;` inside the upstream block and verify each server name resolves correctly.
Built-in OSS Nginx only does passive checks (mark dead on failure).
Fix: Use NGINX Plus or the `nginx_upstream_check_module` patch for active checks; the `/health` endpoint here probes once per request.
Least connections (`least_conn`) for long-lived requests (websockets, slow APIs). Round robin for short stateless requests. IP hash if you can't move session state out of the upstream. Consistent hash for cache-friendly partitioning.
The reverse-proxy generator targets a single upstream URL. The load balancer generator emits an `upstream { ... }` block with multiple `server` lines and a method, then proxies to the named upstream.
Append `weight=N` or `backup` to a server line after copying, e.g. `server app1:3000 weight=3;`. The form intentionally keeps inputs simple.
OSS Nginx only does passive checks (a server is marked unavailable for `fail_timeout` after `max_fails`). Active checks need NGINX Plus or a third-party module.
`ip_hash` always uses the client IP. `hash $remote_addr consistent` uses a configurable key with consistent hashing — better for cache partitioning when servers are added or removed.
Use the Nginx SSL Config Generator for the front server, then paste the upstream block from this tool. Or extend the output with the `listen 443 ssl;` directives.
Round out the load-balanced stack. You can also browse the full DevOps & Infra category for more options.
Generate a production-ready nginx.conf for reverse proxying with proxy_pass, headers, timeouts, and gzip from a focused form
Generate an HTTPS-ready nginx.conf with SSL certificate paths, modern protocols, ciphers, HSTS, and HTTP-to-HTTPS redirect
Generate an nginx config for proxying WebSocket connections with Upgrade and Connection headers and long read timeouts
Validate docker-compose.yml against the Compose Spec schema with hand-written lints (port collisions, undefined networks, depends_on cycles)
Explore multi-document Kubernetes manifests grouped by kind with a cross-reference graph (Service to Deployment, ConfigMap mounts, Ingress backends)
Generate an nginx.conf for serving a static site with try_files, SPA fallback, gzip, brotli, and aggressive cache headers
Edit .env files in a key/value table with type detection, masked secrets, duplicate-key warnings, and export to JSON, YAML, shell, or docker-compose
sudo nginx -t && sudo systemctl reload nginxcontent bottom • up to 300x250