Config Commands
Learn Nginx configuration file structure, server blocks (virtual hosts), location directives, and best practices for organizing complex configurations with includes and modular design.
8 commands
Pro Tips
Organize server blocks in `/etc/nginx/sites-available/` and symlink to `sites-enabled/` for easy management.
Use `include` directives to break large configs into modular files (e.g., `ssl-params.conf`, `security-headers.conf`).
Set appropriate `server_names_hash_bucket_size` if you have many long domain names to avoid startup errors.
Place most specific `location` blocks first - Nginx uses longest prefix match for location selection.
Common Mistakes
The `root` directive in location blocks is inherited but can be overridden - be careful with nested locations.
Changes to nginx.conf require a reload/restart, but Nginx validates syntax before applying to prevent downtime.