メインコンテンツへスキップ
kitlocal.dev

NGINXチートシート

ローカルで実行

100% ブラウザ内で処理されます。入力や出力が端末の外に送信されることはありません。

NGINX の設定ディレクティブと CLI 操作:server ブロック、リバースプロキシヘッダー、WebSocket、TLS、キャッシュ、圧縮、レート制限。

動作の仕組み

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`.

サバイバルキット

最初に覚えるべき最小限のコマンド。

40 件のコマンド

キーボードショートカット/検索にフォーカスJK選択を移動C選択項目をコピーF選択項目をブックマークEsc検索をクリア

CLI Check, Reload & Logs

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

  • 基本

    Test all included nginx configuration files for syntax and path errors

    nginx -t

    使いどころ

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

    コマンドの内訳

    -t
    Parse config and test validity without applying

    実例

    sudo nginx -t

    実行結果

    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.

KitLocalツールで試す

2026/11/15 に検証済み · NGINX 1.26+ / mainline で検証済み

出典: NGINX Documentation · NGINX ngx_http_proxy_module

山括弧内の内容は実際の値に置き換えてください。コマンドは公式ドキュメントに基づいており、実例は記載されたバージョンで実行確認されています。