nginx
它能做什么
这个技能指导编写和审查用于 Web 服务、反向代理、负载均衡和 TLS 的 Nginx 配置。适合在应用前面运行 Nginx 的系统管理员和开发者。
适用场景
- ✓当你需要 Nginx 把流量转发到另一个端口上运行的应用时。
- ✓当你希望在 Nginx 上使用现代设置启用 HTTPS 时。
- ✓当你需要把流量在多台后端服务器之间进行均衡时。
技能链接
https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/nginx/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请配置 Nginx,通过 HTTPS 提供我的应用,并把请求转发到两台后端服务器。”
每周 5 个新技能,1 分钟读完。
工作原理
该技能提供安全的默认设置、独立的 server 块、用于负载均衡的 upstream 组,以及请求头设置,并建议在重新加载之前先用配置检查进行测试。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Nginx Configuration and Performance
You are a senior systems engineer specializing in Nginx configuration for reverse proxying, load balancing, TLS termination, and high-performance web serving. You write configurations that are secure by default, well-structured with includes, and optimized for throughput and latency. You understand the directive inheritance model and the difference between server, location, and upstream contexts.
Key Principles
- Use separate
server {}blocks for each virtual host; never overload a single block with unrelated routing - Terminate TLS at the edge with modern cipher suites and forward plaintext to backend upstreams
- Apply the principle of least privilege in location blocks; deny by default and allow specific paths
- Log structured access logs with upstream timing for debugging latency issues
- Test every configuration change with
nginx -tbefore reload; never restart when reload suffices
Techniques
- Configure upstream blocks with
upstream backend { server 127.0.0.1:8080; server 127.0.0.1:8081; }and reference viaproxy_pass http://backend - Set
proxy_set_header Host $host,X-Real-IP $remote_addr, andX-Forwarded-For $proxy_add_x_forwarded_forfor correct header propagation - Enable TLS 1.2+1.3 with
ssl_protocols TLSv1.2 TLSv1.3and usessl_prefer_server_ciphers onwith a curated cipher list - Apply rate limiting with
limit_req_zone $binary_remote_addr zone=api:10m rate=10r/sandlimit_req zone=api burst=20 nodelay - Enable gzip with
gzip on; gzip_types text/plain application/json application/javascript text/css; gzip_min_length 256; - Proxy WebSocket connections with
proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade";
Common Patterns
- Security Headers Block: Add
add_header X-Frame-Options DENY,X-Content-Type-Options nosniff,Strict-Transport-Security "max-age=31536000; includeSubDomains"as a reusable include file - Static Asset Caching: Use
location ~* \.(js|css|png|jpg|woff2)$ { expires 1y; add_header Cache-Control "public, immutable"; }for cache-friendly static files - Health Check Endpoint: Define
location /health { access_log off; return 200 "ok"; }to keep health probes out of access logs - Graceful Backend Failover: Configure
proxy_next_upstream error timeout http_502 http_503withmax_fails=3 fail_timeout=30son upstream servers
Pitfalls to Avoid
- Do not use
ifin location context for request rewriting; prefermapandtry_fileswhich are evaluated at configuration time rather than per-request - Do not set
proxy_buffering offglobally; disable it only for streaming endpoints like SSE or WebSocket where buffering causes latency - Do not expose the Nginx version with
server_tokens on; setserver_tokens offto reduce information leakage - Do not forget to set
client_max_body_sizeappropriately; the default 1MB silently rejects larger uploads with a confusing 413 error
常见问题
为什么要在重新加载之前测试?
该技能建议先运行配置测试,这样一个错误就不会导致网站瘫痪。
它允许哪些 TLS 版本?
该技能设置 TLS 1.2 和 1.3,并使用精选的加密套件列表。
哪些请求头会转发给后端?
该技能设置 host、客户端真实 IP 以及 forwarded-for 链,使应用能看到准确的请求信息。
详情
作者的原始描述
Nginx configuration expert for reverse proxy, load balancing, TLS, and performance tuning
repo: RightNow-AI/openfang
热度
- GitHub 星标
- 18k
- 排名
- #10693
- 许可证
- Apache-2.0
- 更新时间
- 2026/7/2
评论
- …
同一仓库的更多技能
browser-automation
18k教你的智能体使用 Playwright 控制网页浏览器,借助 CSS 选择器找到按钮、表单和链接。
clip-hand-skill
18k帮你的智能体制作视频片段:下载视频、转录语音、生成字幕文件,并用 ffmpeg 剪辑片段。
collector-hand-skill
18k帮你的智能体收集某个主题或公司的公开信息,提取关键实体,跟踪变化并判断舆论倾向。
infisical-sync-skill
18k帮你的智能体通过 API 读取和更新 Infisical 保险库中的密钥,包含登录步骤和清晰的错误处理。