Skip to main content
kitlocal.dev

NGINX Cheatsheet

Runs locally

100% processed in your browser. Inputs and outputs never leave your device.

NGINX configuration directives and CLI operations: server blocks, reverse proxy headers, WebSockets, TLS, caching, compression, and rate limiting.

How it works

NGINX resolves `server { listen; server_name; }` first, then picks the most specific `location` block, forwarding or serving static files; always validate with `nginx -t` before `reload`.

Survival kit

The few commands to learn first.

40 commands

Keyboard shortcuts/Focus searchJKMove selectionCCopy selectedFBookmark selectedEscClear search

CLI Check, Reload & Logs

Validate syntax, reload without dropping connections, and inspect runtime config.

  • Essential

    Test all included nginx configuration files for syntax and path errors

    nginx -t

    When to use it

    Never reload NGINX without testing first; broken config aborts reload safely only if checked.

    Breakdown

    -t
    Parse config and test validity without applying

    Example

    sudo nginx -t

    Result

    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful

Server Blocks, Locations & Static Files

Understand location matching precedence, SPA fallbacks, and clean redirects.

Reverse Proxy, Upstreams & WebSockets

Forward client IPs, HTTP/1.1 keepalives, WebSocket upgrades, and timeouts.

TLS, Security Headers & Rate Limits

Enforce HTTPS, TLS 1.2/1.3, security headers, and per-IP rate/size caps.

Compression, Caching & Tuning

Enable gzip, cache-control headers, worker limits, and proxy microcaching.

Try it in a KitLocal tool

Checked on Nov 15, 2026 · Checked against NGINX 1.26+ / mainline

Sources: NGINX Documentation · NGINX ngx_http_proxy_module

Replace anything in angle brackets with your own values. Commands come from the official documentation, and examples were run on the version shown.