Nginx Config Generator
站点必填
多站点批量可选
每行一个站点,格式为 域名 | 根目录 | 上游 | 类型;后三段可留空,留空时继承上方的类型与对应字段。填了内容就不会再生成上面那个单站点。
未启用批量性能与安全
关闭监听与连接官方参数
代理细节proxy_*
访问与安全allow / deny / CORS
日志与错误页log / error_page
SSL 高级仅 HTTPS
官方指令全覆盖http / upstream / server
Nginx 官方指令两百余条,无法逐条做成按钮,因此按作用域给出自由入口:http 级、upstream 块、server 级任意官方指令都能直接写,插件负责缩进、补分号与位置校验。
官方指令库检索后一键插入作用域
内置常用官方指令的语法模板与作用域,检索后点「插入」会追加到对应文本框并补分号;未收录的新指令仍可直接手写。
自定义指令server / location
一行一条,不写分号也会自动补;注释以 # 开头。
生成的配置—
风险扫描
上线校验复制到终端
How to Use
📖 What it does
The hard part of Nginx is not syntax but remembering which directives belong together: which certificate lines HTTPS needs, which headers a proxy must forward, how long static assets should be cached, and where rate limiting goes. This tool turns those choices into checkboxes and prints a deployable server block with a note above each section.
It only assembles text. It never connects to your server or reads existing configuration, so the result is a safe starting point you can paste into a sites directory or use as a template.
Changing an option recalculates the block in about 5 ms behind a 120 ms debounce so keystrokes never rebuild the whole file repeatedly.
Lines are collected in an array and joined once instead of concatenated string by string; a typical result is 40 to 90 lines, and switching site type leaves nothing from the previous build.
The workspace exposes 40 controls, from 站点类型 to 关闭 session ticket(前向保密), and every one of them only affects the local rendering: nothing is sent back to a server.
Ranges and defaults: 站点类型 (静态站点 / 反向代理 / PHP 站点 / 单页应用(SPA)), 限流:每秒请求数(0 关闭) (0–200(默认 0)), proxy_buffering (on(默认,先缓冲再回传) / off(SSE / 流式接口)), 主 location 修饰符 (前缀匹配 / / 精确匹配 = / 前缀优先 ^~ / 正则 ~(区分大小写) / 正则 ~*(忽略大小写)), CORS (关闭 / 允许任意来源(无凭证) / 允许指定来源 + 凭证), error_log 级别 (默认 / warn / error / crit). Values outside the slider range are rejected rather than silently clamped.
The 站点类型 control is a dropdown with the options 静态站点 / 反向代理 / PHP 站点 / 单页应用(SPA); the active option is what the export uses, so check it after every reload.
The 主域名 control takes free text and feeds it straight into the preview without sending it anywhere.
The 站点根目录 control takes free text and feeds it straight into the preview without sending it anywhere.
The 上游地址 control takes free text and feeds it straight into the preview without sending it anywhere.
The 启用 HTTPS(含 80 跳转) control toggles a single behaviour on or off; the preview updates at once and the exported file follows the current state.
✨ Features
- Four site types: static, reverse proxy, PHP and single-page app, each with its own location and try_files pattern.
- Multi-site batch: one line per site with domain | root | upstream | type; empty columns inherit the defaults above.
- Tiered risk scan: blocking / caution / tip levels covering missing upstream port, relative document root, 127.0.0.1 inside containers, HSTS without HTTPS, rate limits that are too low and duplicate zones.
- Verification commands: nginx -t plus reload, protocol-aware curl checks and an openssl certificate expiry check when HTTPS is on.
- HTTPS and HTTP/2: adds the 443 listener, certificate paths, TLS versions and the port 80 redirect block.
- Performance and security switches: gzip, long-lived static caching, automatic burst sizing, HSTS and three baseline headers, each with a usage note.
🚀 How to use
- Pick a site type and fill the domain; reverse proxies need host:port, static sites need an absolute document root.
- Toggle HTTPS, HTTP/2, gzip, caching, rate limiting and security headers; the output and risk list recompute instantly.
- To change several sites at once, write one per line as domain | root | upstream | type and leave columns empty to inherit defaults.
- Read the risk scan: clear every blocking item first, then confirm cautions; tips are optional optimisations.
- Copy the verification commands and roll out as backup, write, nginx -t, reload, then curl to confirm redirects and headers.
⚠️ Before you rely on it
- Text only: no syntax validation and no server connection - always run nginx -t before reloading.
- Pipe-separated batch: domain | root | upstream | type, always in that order; only empty columns inherit defaults.
- Replace certificate paths: defaults follow the common Let's Encrypt layout, your real paths may differ.
- Ports matter: use 127.0.0.1:port on the host and service-name:port inside containers; a missing port is a blocking issue.
- Rate limit zone belongs to http: limit_req_zone must sit in http{}, so it is emitted per site above the server block.
- HSTS is sticky: once enabled browsers force HTTPS for a year; skip includeSubDomains until every subdomain is ready.
- Behind a CDN: origin requests already carry X-Forwarded-Proto, so an unconditional 301 can loop - use the commented conditional redirect.
- All input stays in the browser and resets on reload.
Questions people ask: Q: Can I deploy the output as it is? A: Use it as a starting point, but replace the certificate paths, document root and upstream port. Run nginx -t and reload during a quiet window. Q: Why no upstream load-balancing block? A: A single upstream reads more clearly through proxy_pass. For several servers, replace proxy_pass with an upstream name. Q: Why limit requests per second instead of connections? A: Bursts are the common problem, and rps with burst matches real traffic. Connection limits need limit_conn, which you add by hand. Q: The output contains limit_req_zone but I only want the redirect. How do I remove it? A: Drag the requests-per-second slider back to zero: the zone and the limit_req line are removed as a pair, so no half-configured limit is left behind. Q: q A: a Q: q A: a Q: q A: a Q: Can the output go straight to a live server? A: As a starting point, yes, but replace the certificate paths, root and upstream port, and always run nginx -t before reloading.
Typical use: Updating several sites on one server, promoting staging config to production, or inheriting an Nginx setup that needs security and caching policies.
What you can enter: S i t e t y p e , d o m a i n , d o c u m e n t r o o t o r u p s t r e a m ; i n b a t c h m o d e o n e s i t e p e r l i n e w i t h p i p e - s e p a r a t e d c o l u m n s .
What you get back: A r e a d y - t o - l a n d s e r v e r b l o c k , a t h r e e - t i e r r i s k l i s t a n d c o p y - r e a d y v e r i f i c a t i o n c o m m a n d s .
Limits to keep in mind: Generates text only; it does not validate syntax, connect to a server or read existing configuration. No upstream groups, no stream (L4) proxying and no Lua blocks. Certificate paths are common defaults and must be replaced with real ones. Keep batch runs under about ten sites so rollbacks stay traceable. Risk rules are heuristics and do not replace nginx -t, module checks or real traffic testing.