Server foundations
Test, reload, and roll back
Apply configuration changes without replacing a working server with a syntax error or unverified behavior.
8 minute lesson
Always test the complete effective configuration before asking Nginx to reload it.
sudo nginx -t checks syntax and referenced files. A successful reload preserves existing connections. Keep the previous file until HTTP and application health checks pass.
Make a harmless header change. Test, reload, check the response, then restore the previous file and repeat the same safe sequence.
Never reload an untested configuration:
sudo nginx -t
sudo systemctl reload nginx
sudo systemctl status nginx --no-pager
Keep the previous configuration available before editing. After reload, request the exact hostname and path with curl. A successful syntax check cannot detect a wrong server block, upstream port, certificate name, or application response, so the external smoke test is part of the change.
Lesson completed