Pcornel
Web Infrastructure · Web Services

Nginx

Cheat sheet · https://pcornel.dk/topic.php?topic=2876

Back to the Topic

Answer

Nginx is an event-driven web server and reverse proxy, configured with server blocks (virtual hosts) and location blocks, commonly in /etc/nginx/nginx.conf, conf.d/ and sites-enabled/.

Remember

nginx -t before every reload. nginx -T prints the full merged config. The first matching server block for a port is the default — unknown names land there. 502 means the upstream refused or crashed; 504 means it timed out.

First checks

  • systemctl status nginx|apache2|httpd — web server state
  • nginx -t / apachectl configtest — configuration test
  • ss -ltnp | grep -E ':80|:443' — listening ports
  • curl -vI https://<name> — response, headers and TLS
  • tail -f /var/log/nginx/error.log — error log (or apache2/httpd)

Commands

systemctl reload

Verify in this order

request → listen socket → server_name match → location → static file or proxy_pass → response

Where it usually breaks

First mismatch in persistent intent → provider/parser/generator → kernel/userspace runtime → dependency/security context → logs/counters → consumer-visible read-back; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2876

Confirmation

Confirm action

Continue?