nginx uses an asynchronous, event-driven worker model. The main process reads configuration, while worker processes handle connections. include pulls in snippets from conf.d or per-site files; always run nginx -t before reload. Inside http{}, server{} groups virtual hosts and location chooses how to handle URLs: longest-prefix wins unless a regex (~) or exact (=) match applies, and ^~ stops further regex search after a prefix match.
| Concern | Directive / idea | Tip |
|---|---|---|
| Reload safely | nginx -t then nginx -s reload | Invalid config never swaps workers |
| Connection scale | worker_connections in events{} | Align with ulimit / worker_rlimit_nofile |
| Static + SPA | try_files / root | Avoid serving unintended directory listings |
Related
Nginx server blocks, reverse proxy, performance tuning, common nginx errors