Nginx Cheatsheet

Nginx configuration, server blocks, and reverse proxy setup

Web Server6 commandsintermediate

Overview

Nginx is a lightweight, high-performance web server and reverse proxy.

Why It Matters

Nginx is a high-performance web server and reverse proxy used by millions of websites.

Essential Commands

nginx -t

Test nginx configuration syntax

sudo systemctl reload nginx

Reload config without full restart

sudo systemctl restart nginx

Restart nginx service

sudo tail -f /var/log/nginx/access.log

Follow access logs live

sudo tail -f /var/log/nginx/error.log

Follow error logs live

sudo ln -s /etc/nginx/sites-available/app /etc/nginx/sites-enabled/

Enable virtual host config

Quick Start

Master configure server blocks for multiple sites first

Key Concepts

Configure server blocks for multiple sites

Set up reverse proxies and load balancing

Enable HTTPS and SSL/TLS certificates

Pro Tips

  • Combine multiple commands for powerful workflows
  • Use aliases to speed up your command entry
  • Create scripts to automate repetitive tasks

Common Pitfalls to Avoid

  • Forgetting to check the documentation for edge cases
  • Running commands without understanding their full impact
  • Not testing changes in a safe environment first

Related Resources

10 items