Verified SOP & TutorialAudited Score 98/100

The Complete Production SOP: How to Deploy and Run Production Nginx Hardener & Proxy in Autonomous AI Agents

Harden Nginx reverse proxies with TLS 1.3 and Cloudflare real IP using autonomous agent rules in Codex, Claude Code, and Cursor.

Target Runtimes:codexclaude-codecursorwindsurf
5 min read • Updated for 2026

Technical Overview & Architectural Context

Autonomous coding agents frequently generate vulnerable Nginx configurations when prompted for reverse proxies. Unconstrained models tend to suggest deprecated SSL ciphers (TLSv1.0/1.1), omit buffer overflow protections (`client_body_buffer_size`), fail to configure `real_ip_header` against spoofed `X-Forwarded-For` headers, and configure rate limiting inside invalid contexts (`server` blocks instead of `http`). The Production Nginx Hardener & Proxy skill enforces deterministic constraints on autonomous agents across Codex, Claude Code, Cursor, and Windsurf. It injects hardened baseline templates that mandate TLS 1.3 only, enforce strict Cloudflare CIDR whitelisting for client IP restoration, install HTTP request rate-limiting pools, drop common scraper user-agents, and require execution of `nginx -t` validation before finalizing changes.

Prerequisites & Environment Requirements

Codex Desktop, Claude Code CLI, Cursor IDE, or Windsurf installed
Local Nginx binary (>=1.20+) or Docker daemon available in workspace for syntax linting
Git 2.40+ initialized within your target infrastructure or repository workspace

Verified Search Intents & Long-Tail Queries Solved

SEO Audit Score: 98/100

This operational tutorial is engineered to provide deterministic solutions for these developer search queries:

#install nginx-hardener in cursor ide#claude code nginx-hardener rules#codex desktop nginx-hardener setup tutorial#how to fix nginx-hardener agent execution error#nginx tls 1.3 cloudflare real ip ai skill#deterministic devops agent SOP#nginx-hardener sandbox permissions and security score#nginx rate limiting and bot blocking agent triggers

Step-by-Step Execution Playbook

1

Local Environment Setup & SKILL.md Mounting

Create the workspace skill manifest directory and inject the deterministic Nginx hardening rules.

Autonomous runtimes parse directory-specific rules to shape system prompts. We mount the SKILL.md specification to `.agents/skills/nginx-hardener` (for universal loaders) and link it into `.cursor/rules/` or Claude Code workspace configs so the agent automatically loads the hardening parameters upon reading Nginx configuration files.

Terminal Command
mkdir -p .agents/skills/nginx-hardener && curl -fsSL https://askills.dev/api/skills/nginx-hardener/raw -o .agents/skills/nginx-hardener/SKILL.md
.agents/skills/nginx-hardener/SKILL.md
---
name: "nginx-hardener"
description: "Harden Nginx reverse proxies with TLS 1.3, Cloudflare real IP, bot blocking, and gzip offloading."
category: "devops"
security_score: 98
---

# Production Nginx Hardener SOP

1. Enforce TLS 1.3 exclusively: `ssl_protocols TLSv1.3;`
2. Extract Real Client IP solely from verified Cloudflare CIDRs via `ngx_http_realip_module`.
3. Rate limiting MUST be initialized in the `http` block via `limit_req_zone $binary_remote_addr zone=api_limit:10m rate=10r/s;`.
4. Close connections instantly for known malicious user agents via `$bad_bot` mapping.
5. Run `nginx -t -c <file>` to assert configuration validity prior to completing task.
Production Pro-Tip

Store the skill in `.agents/skills/` and symlink into `.cursorrules` or `.claude.md` to conserve agent context tokens by avoiding file duplication across multiple runtime config paths.

Sandbox Gotcha

AI agents operating in unprivileged sandboxes cannot bind port 80 or 443 directly. Instruct the agent to test bindings against unprivileged ports (8080/8443) or validate syntax with the `-t` flag without starting systemd units.

2

Environment Secrets & Cloudflare Ingress Pinning

Inject Cloudflare trusted IP ranges into a dedicated include file without exposing sensitive workspace variables.

To prevent IP spoofing when running behind Cloudflare or another edge reverse proxy, the agent must generate a dedicated `cloudflare_ips.conf` based on official Cloudflare IP ranges. This ensures `set_real_ip_from` directives are isolated and modular.

Terminal Command
mkdir -p conf/nginx/conf.d && curl -s https://www.cloudflare.com/ips-v4 | awk '{print "set_real_ip_from " $1 ";"}' > conf/nginx/conf.d/cloudflare_ips.conf && echo "real_ip_header CF-Connecting-IP;" >> conf/nginx/conf.d/cloudflare_ips.conf
Production Pro-Tip

Separate dynamic network blocks (like proxy IP whitelists) from main `nginx.conf` so agents do not re-read and consume tokens on long IP lists during iterative code refactoring.

Sandbox Gotcha

Do not hardcode production private TLS keys into agent instruction files or prompts. Reference file paths (`/etc/ssl/certs/...`) and keep private keys in encrypted secrets stores.

3

Intent Matching & Trigger Invocation

Trigger deterministic proxy generation using validated prompt parameters.

Provide the agent with explicit reverse proxy targets and security requirements. The skill's frontmatter matches keywords such as 'reverse proxy', 'TLS 1.3', 'rate limit', and 'harden nginx', shifting the agent into strict enforcement mode.

Production Pro-Tip

Specify upstream ports and service names in your prompt so the agent generates precise `upstream` upstream blocks rather than generic localhost pointers.

Sandbox Gotcha

Ensure that your prompt does not instruct the agent to generate deprecated directives like `ssl_ciphers HIGH:!aNULL:!MD5;` which are redundant and conflicting when TLS 1.3 is enforced.

4

Verification, Linting & Output Quality Gate

Execute non-destructive Nginx configuration verification inside an isolated container sandbox.

The skill mandates a self-healing verification cycle. The agent must run an automated syntax check using a temporary container or isolated process before marking the task complete.

Terminal Command
docker run --rm -v "$PWD/conf/nginx:/etc/nginx:ro" nginx:alpine nginx -t
Production Pro-Tip

Use `git diff --stat conf/nginx/` before committing agent-generated configs to confirm no global default buffers or timeouts were unintentionally altered.

Sandbox Gotcha

Container sandboxes may fail if paths inside `nginx.conf` reference host-specific directories that are not mounted into the test container.

Real-World Scenario: Harden an Edge Reverse Proxy for a Node.js Microservice behind Cloudflare

Tested Trigger Prompt (Feed directly into Codex, Claude, or Cursor):

“Generate a production-hardened Nginx reverse proxy configuration for an internal microservice running at 127.0.0.1:3000. Apply the nginx-hardener skill: enforce TLS 1.3, isolate Cloudflare client IPs, block Semrush/Ahrefs bots with 444 responses, add strict rate limiting, and test the syntax.”

Deterministic Agent Verification Pipeline:
Reads repository layout, detects `conf/nginx/nginx.conf`, and injects `limit_req_zone` and `map $http_user_agent $bad_bot` in the `http` context.
Creates `conf/nginx/conf.d/cloudflare_ips.conf` containing valid Cloudflare IPv4 ranges and assigns `real_ip_header CF-Connecting-IP;`.
Constructs the `server` block with `ssl_protocols TLSv1.3;`, applies security headers (HSTS, X-Frame-Options, CSP), and proxies traffic to `http://127.0.0.1:3000` with buffer restrictions.
Executes `docker run --rm -v "$PWD/conf/nginx:/etc/nginx:ro" nginx:alpine nginx -t` to verify syntax passes with zero errors.

Runtime Troubleshooting & Failure Modes

Error: nginx: [emerg] "limit_req_zone" directive is not allowed here in /etc/nginx/conf.d/proxy.conf:12

Root Cause: The agent attempted to declare a shared memory rate-limiting zone inside a `server` or `location` block instead of the root `http` block context.

Resolution Command / Fix:
Move the `limit_req_zone` declaration to an included file loaded directly by the `http` block: `echo 'limit_req_zone $binary_remote_addr zone=api_limit:10m rate=10r/s;' > conf/nginx/conf.d/rate_limits.conf`
Error: nginx: [emerg] ssl_stapling ignored, issuer certificate not found for certificate "/etc/ssl/certs/server.crt"

Root Cause: The agent enabled `ssl_stapling on;` without specifying the intermediate CA bundle via `ssl_trusted_certificate` or using a self-signed certificate in the workspace.

Resolution Command / Fix:
Add the CA chain path to the SSL configuration: `sed -i 's|ssl_stapling on;|ssl_stapling off; # Disabled in local/staging without intermediate bundle|g' conf/nginx/nginx.conf`

Frequently Asked Questions (Production Nginx Hardener & Proxy SOP)

Q:Can I use Production Nginx Hardener & Proxy across Codex, Claude Code, and Cursor simultaneously?

Yes. The SKILL.md specification is completely runtime-agnostic. You can mount it within `.cursor/rules/`, include it in your Claude Code system prompt file (`.claude.md`), or place it into the workspace root for Codex and Windsurf agents.

Q:How does Production Nginx Hardener & Proxy prevent context window overflow during long agent sessions?

By establishing declarative constraints and delegating heavy configurations (such as IP CIDR tables and bot lists) to modular include files (`include conf.d/*.conf;`), keeping core agent reasoning loops under 400 tokens.

Q:Does this skill require escalated root or container permissions?

No. The skill is designed to operate safely inside unprivileged workspaces with a security score of 98/100. All validation steps use non-root dry runs (`nginx -t -p . -c ...`) or unprivileged Docker test containers.

Ready to equip your autonomous agent with Production Nginx Hardener & Proxy?

Copy the complete audited SKILL.md specification or download the 1-click zip bundle directly from our verified registry.

Get 1-Click Install Spec