Back openDesk Edu for a sovereign, open-source education â every vote counts.
Vote nowSave products you love by clicking the heart icon.
Quick reference for Nginx web server, reverse proxy, and load balancer configuration
A dedicated reverse proxy layer is the single most impactful security investment you can make for a web application. It handles SSL termination, rate limiting, WAF inspection, and upstream routing â all concerns that individual application servers should not manage themselves.
The stack presented here combines three battle-tested tools: Nginx for request handling, Certbot for automatic SSL, and CrowdSec for behavioral WAF/IPS.
Nginx's event-driven architecture means worker configuration directly impacts throughput:
worker_processes auto;
worker_connections 1024;
multi_accept on;
use epoll;
auto worker processes = number of CPU coresepoll is the Linux-native event loop â significantly more efficient than select or pollSSL configuration follows Mozilla's "Modern" profile:
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:...;
ssl_prefer_server_ciphers off;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
ssl_session_tickets off;
Key decisions:
Rate limiting is configured per zone, not per-request:
limit_req_zone $binary_remote_addr zone=api:10m rate=30r/s;
limit_conn_zone $binary_remote_addr zone=addr:10m;
The $binary_remote_addr key uses the client IP in binary format (4 bytes for IPv4, 16 for IPv6), minimizing memory usage. The 10MB zone stores ~80,000 entries.
The Certbot container handles the full certificate lifecycle:
/var/www/certbot0 */12 * * *) to check for renewalsCertbot supports multiple challenge types. Webroot mode (--webroot -w /var/www/certbot) is the best choice for this stack:
CrowdSec is a behavior-based security engine. It ingests logs, detects attacks using community-contributed scenarios, and blocks malicious IPs at the reverse proxy level:
The CrowdSec container is configured with the Nginx collection, which includes:
crowdsecurity/nginx: Base Nginx parsercrowdsecurity/http-cve: HTTP vulnerability scanning detectioncrowdsecurity/http-bf: Brute force detection on login endpointscrowdsecurity/http-path-traversal: Path traversal attemptsThe bouncer runs as a separate container (nftables-based) that communicates with CrowdSec via API:
docker compose exec crowdsec cscli decisions list
# Manually ban an IP
docker compose exec crowdsec cscli decisions add --ip 1.2.3.4 --duration 24h
server_tokens off) â prevents version disclosureclient_max_body_size per application â default 1MB blocks file uploadslimit_req per upstream â prevents one slow service from starving othersproxy_read_timeout appropriately â long-polling endpoints need 300s+/etc/letsencrypt â losing SSL certs requires re-issuance and re-propagationcscli metrics shows detection volume and blocked IPs