跳转到主要内容
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

请将尖括号内的内容替换为你自己的实际值。所有命令均来自官方文档,示例均在标明版本上实测运行。