nginx

Guidance for configuring Nginx, a web server and reverse proxy that can route requests to application servers. It covers proxying, load balancing, TLS, access controls, logging, and performance.

In plain words
What is it for?
Use it when setting up virtual hosts, forwarding traffic to backend services, balancing requests, terminating HTTPS, or tuning an Nginx deployment. Run nginx -t to check a configuration before reloading it.
Why use it?
It helps keep Nginx configurations organized and safer by default while making backend routing and latency easier to diagnose. It also emphasizes testing configuration changes before reloading the service.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/librefang/librefang-registry/nginx
Any agent
npx skills add librefang/librefang-registry --skill nginx
Clone the repo
git clone --depth 1 https://github.com/librefang/librefang-registry

Made for: Claude Code, Codex.

Per session 20 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 764 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin 97% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00020 $0.00764
Opus 5 $0.00010 $0.00382
Sonnet 5 $0.00004 $0.00153
Haiku 4.5 $0.00002 $0.00076

Measured 2d ago against content hash d00ad40db639, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

nginx scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

97% identical to nginx — 3 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

skills/nginx/SKILL.md · 42 lines

How it starts

The opening of the file, as written. The whole thing — 42 lines — stays where its author put it; the contents beside it link to each section on 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

Read the full file on GitHub · 42 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 42 lines · 20 tokens per session scan A d00ad40db639

Subscribe to this mod's changes

nginx is a skill published in the GitHub repository librefang/librefang-registry (11 stars, last pushed 8d ago), licensed MIT. It adds 20 tokens to every session and 764 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. It is 97% identical to nginx, differing in 3 lines, and is treated as a copy.