nginx Cheatsheet

Top configs.

Testing config

Validating nginx config before reload is the single highest-value habit. nginx -t catches syntax errors and missing files before they take down a working server; running it first is muscle memory worth building.

Reload and restart

Reload, not restart. Reload sends SIGHUP and forks new workers without dropping connections; restart kills connections and lengthens any incident.

Logs and debugging

Logs are where every nginx investigation starts. Access, error, and debug logs serve different purposes; reach for the right one and the answer is often visible immediately.

Upstream patterns

Upstream blocks are where nginx earns its load-balancer keep. The algorithm choice, health-check model, and keepalive setting decide whether nginx adds latency or removes it.

Performance tuning

Performance tuning is its own discipline. Workers, sendfile, file descriptors, and compression all stack; getting the basics right matters more than tuning any single knob.