NGINX
medium 28 minNGINX (say "engine x") is a web server, reverse proxy, load balancer and response cache.
Remember it
The few things worth knowing cold, and how to make them stick.
Memory hook
One porter, many bells: never wait at one door.
A hotel porter who leaves a bell at every slow door, serves the next guest, and returns when the bell rings. One heavy trunk stops everything, so hire one porter per core.
Cheat sheet
- worker_processes
- default 1; use auto
- worker_connections
- default 512
- keepalive_timeout
- default 75 s
- client_max_body_size
- default 1 MB
- proxy_buffering
- default on
- proxy_read_timeout
- default 60 s
- proxy_cache_lock
- default off, wait 5 s
- limit_req_status
- default 503
- max_fails, fail_timeout
- 1, 10 s
- Upstream keepalive
- 32 per worker since 1.29.7
- TLS default
- 1.2 and 1.3
- Licence
- 2-clause BSD
Spot it when you see
- Several app servers behind one address.
- Slow clients tie up app workers.
- A burst on public pages.
- TLS and limits in one place.
Tricks that stick
- Host picks the server, URL picks the location.
- Test, then reload.
- Lock the cache, keep the stale copy.
- Zone means shared by workers, not by machines.
Do not forget
- Caching private pages.
- Limits counted per machine.
- Upstream without a zone.
- Trusting client-sent forwarded headers.
- Only one NGINX.
- A slash too many or too few in `proxy_pass`.