本文へスキップ
Skillpedia
デプロイとクラウド(DevOps)18k · #10693

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に貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/nginx/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“アプリをHTTPSで提供し、リクエストを2台のバックエンドサーバーに転送するようNginxを設定してください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

このスキルは、安全な既定値、サーバーブロックの分離、負荷分散のための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 -t before 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 via proxy_pass http://backend
  • Set proxy_set_header Host $host, X-Real-IP $remote_addr, and X-Forwarded-For $proxy_add_x_forwarded_for for correct header propagation
  • Enable TLS 1.2+1.3 with ssl_protocols TLSv1.2 TLSv1.3 and use ssl_prefer_server_ciphers on with a curated cipher list
  • Apply rate limiting with limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s and limit_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_503 with max_fails=3 fail_timeout=30s on upstream servers

Pitfalls to Avoid

  • Do not use if in location context for request rewriting; prefer map and try_files which are evaluated at configuration time rather than per-request
  • Do not set proxy_buffering off globally; disable it only for streaming endpoints like SSE or WebSocket where buffering causes latency
  • Do not expose the Nginx version with server_tokens on; set server_tokens off to reduce information leakage
  • Do not forget to set client_max_body_size appropriately; the default 1MB silently rejects larger uploads with a confusing 413 error
よくある質問

再読み込みの前にテストする理由は何ですか?

設定ミスでサイトが停止しないように、先に設定テストを実行することを勧めているためです。

どのTLSバージョンを許可しますか?

TLS 1.2と1.3を、厳選された暗号スイートとともに許可します。

バックエンドにはどのヘッダーを転送しますか?

ホスト、クライアントの実際のIP、フォワーディングチェーンを設定し、アプリが正確なリクエスト情報を受け取れるようにします。

詳細

作者による元の説明

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

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル