跳至主要內容
kitlocal.dev

NGINX 設定速查表

本機執行

100% 在你的瀏覽器中處理。輸入與輸出絕不會離開你的裝置。

NGINX 設定指令與維運操作: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

請將尖括號內的任何內容替換為你自己的數值。指令均源自官方文件,且範例均在所示版本上實際執行。