This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopshigh PriorityID: nginx-http2-http3-brotli-tls

Nginx HTTP/2, HTTP/3 QUIC & Brotli Dynamic Compression Hardening

Production web server performance and security standard for Nginx. Mandates modern HTTP/2 / HTTP/3 (QUIC) configuration with Brotli compression, strict TLS 1.3 ciphers, and prevents Gzip CRIME/BREACH vulnerability leakage over encrypted HTTPS streams.

Prohibited Anti-Pattern: AI configures obsolete HTTP/1.1 Nginx configs or enables gzip compression on encrypted endpoints without BREACH defense.

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Nginx HTTP/2, HTTP/3 QUIC & Brotli Dynamic Compression Hardening - Production web server performance and security standard for Nginx. Mandates modern HTTP/2 / HTTP/3 (QUIC) configuration with Brotli compression, strict TLS 1.3 ciphers, and prevents Gzip CRIME/BREACH vulnerability leakage over encrypted HTTPS streams.
globs: **/nginx*.conf, **/sites-available/*, **/conf.d/*
alwaysApply: false
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/nginx-http2-http3-brotli-tls"
---

# Nginx HTTP/2, HTTP/3 QUIC & Brotli Dynamic Compression Hardening

> **Severity**: HIGH | **Category**: devops
> **Anti-Pattern Warning**: AI configures obsolete HTTP/1.1 Nginx configs or enables gzip compression on encrypted endpoints without BREACH defense.

## System Constraints
You are an Edge Web Server and Performance Engineer specializing in Nginx. NEVER generate legacy HTTP/1.0 configurations. Always configure modern HTTP/2 (or HTTP/3 QUIC), Brotli compression (brotli_comp_level 6), and modern TLS 1.3 security suites.

## Strict Guidelines
- MUST listen on 443 ssl http2 (or modern listen 443 quic reuseport for HTTP/3).
- MUST enable Brotli compression with brotli_types covering application/javascript, text/css, application/json.
- MUST restrict ssl_protocols strictly to TLSv1.2 and TLSv1.3 (reject SSLv3, TLSv1.0, TLSv1.1).
- MUST configure ssl_session_cache shared:SSL:10m and ssl_session_timeout 1d with session tickets off.
- MUST set add_header Strict-Transport-Security 'max-age=63072000; includeSubDomains; preload' always.

## Bad vs Good Implementations
### Hardened Nginx Server Block with HTTP/2, Brotli and TLS 1.3

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Serves unencrypted HTTP on port 80 without SSL enforcement, lacks HTTP/2 connection multiplexing, and omits HSTS security headers.
```nginx
# FATAL: Insecure HTTP/1.1 config with weak legacy ciphers and missing HSTS
server {
  listen 80;
  server_name api.example.com;
  # Missing HTTPS redirect, vulnerable ciphers, no HTTP/2!
  location / {
    proxy_pass http://127.0.0.1:3000;
  }
}
```

#### Production Standard (Correct)
> **Standard**: Enforces HTTPS redirect, HTTP/2 multiplexing, Brotli compression, strict TLS 1.2/1.3 ciphers, and preloaded HSTS headers.
```nginx
server {
  listen 80;
  server_name api.example.com;
  return 301 https://$host$request_uri;
}

server {
  listen 443 ssl http2;
  server_name api.example.com;

  ssl_certificate /etc/letsencrypt/live/api.example.com/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/api.example.com/privkey.pem;
  ssl_protocols TLSv1.2 TLSv1.3;
  ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;
  ssl_prefer_server_ciphers off;

  # Modern Brotli compression
  brotli on;
  brotli_comp_level 6;
  brotli_types text/plain text/css application/json application/javascript image/svg+xml;

  add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
  add_header X-Content-Type-Options nosniff always;

  location / {
    proxy_pass http://127.0.0.1:3000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $host;
  }
}
```

Recommended MCP Servers (mcp-serverlist.com)

Equip agent with system tools to verify code for this stack.

Recommended Agent Skills (askills.dev)

Ready-to-use executable skill functions tailored to this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Nginx HTTP/2, HTTP/3 QUIC & Brotli Dynamic Compression Hardening

Nginx HTTP/2, HTTP/3 QUIC & Brotli Dynamic Compression Hardening defines an industrial-grade behavioral standard for devops engineering. Production web server performance and security standard for Nginx. Mandates modern HTTP/2 / HTTP/3 (QUIC) configuration with Brotli compression, strict TLS 1.3 ciphers, and prevents Gzip CRIME/BREACH vulnerability leakage over encrypted HTTPS streams. Modern software architectures require strict adherence to deterministic patterns to guarantee high availability, maintainability, and zero security vulnerabilities.

Framework Paradigm Shift & Drift MechanicsLLMs are trained on millions of open-source repositories containing outdated code, legacy idioms, and unpatched antipatterns. When coding assistants generate implementations for this stack, they default to common statistical tokens: AI configures obsolete HTTP/1.1 Nginx configs or enables gzip compression on encrypted endpoints without BREACH defense. Without an explicit system instruction file, developers spend hours debugging silent failures.
Failure Modes & Production Blast Radius

Hazard Analysis: What Breaks Without This Rule

The following failure modes have been cataloged from hundreds of hours of production code reviews where AI assistants produced non-compliant implementations:

Failure ModeAI Symptom (The Anti-Pattern)SeverityProduction Impact & Remedy
AI Hallucination & Deprecation DriftAI configures obsolete HTTP/1.1 Nginx configs or enables gzip compression on encrypted endpoints without BREACH defense.High
Violating this industrial standard introduces regression bugs, security risks, and unexpected runtime failures in production.
Enforce explicit behavioral system directives across all AI coding assistants in your repository.
Silent Architecture InconsistencyAI assistants produce mixed paradigms across files, creating fragmented codebase conventions.Medium
Increases cognitive load during code reviews and leads to maintenance debt across engineering teams.
Pin project conventions in .cursor/rules, CLAUDE.md, and AGENTS.md so all team agents follow identical guardrails.
Architectural Directives in Detail

Step-by-Step Production Directives

Each rule constraint below is injected into the AI agent's system prompt to establish deterministic boundaries:

1

MUST listen on 443 ssl http2 (or modern listen 443 quic reuseport for HTTP/3).

MUST listen on 443 ssl http2 (or modern listen 443 quic reuseport for HTTP/3).

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
2

MUST enable Brotli compression with brotli_types covering application/javascript, text/css, application/json.

MUST enable Brotli compression with brotli_types covering application/javascript, text/css, application/json.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
3

MUST restrict ssl_protocols strictly to TLSv1.2 and TLSv1.3 (reject SSLv3, TLSv1.0, TLSv1.1).

MUST restrict ssl_protocols strictly to TLSv1.2 and TLSv1.3 (reject SSLv3, TLSv1.0, TLSv1.1).

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
4

MUST configure ssl_session_cache shared

MUST configure ssl_session_cache shared:SSL:10m and ssl_session_timeout 1d with session tickets off.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
5

MUST set add_header Strict-Transport-Security 'max-age=63072000

MUST set add_header Strict-Transport-Security 'max-age=63072000; includeSubDomains; preload' always.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
Technical Questions & Answers

Frequently Asked Technical Questions

Common questions developers face when configuring AI coding assistants for this stack:

Q:Why is Nginx HTTP/2, HTTP/3 QUIC & Brotli Dynamic Compression Hardening critical for AI coding assistants?

Production web server performance and security standard for Nginx. Mandates modern HTTP/2 / HTTP/3 (QUIC) configuration with Brotli compression, strict TLS 1.3 ciphers, and prevents Gzip CRIME/BREACH vulnerability leakage over encrypted HTTPS streams. Without explicit behavioral boundaries, AI coding assistants (Cursor, Claude Code, Windsurf, Codex) rely on training data averages, which frequently produce deprecated, inefficient, or vulnerable code patterns.

Q:How does adopting this rule prevent AI hallucinations?

This rule explicitly declares what the AI must avoid (AI configures obsolete HTTP/1.1 Nginx configs or enables gzip compression on encrypted endpoints without BREACH defense.) and prescribes verified positive examples. Grounding the LLM with negative and positive pairs eliminates guesswork.

Q:Which AI coding environments are supported?

This specification is multi-platform compatible: Cursor (.cursor/rules/*.mdc & .cursorrules), Anthropic Claude Code (CLAUDE.md), Windsurf (.windsurfrules), Codex / Cline (AGENTS.md), and GitHub Copilot (.github/copilot-instructions.md).

Q:Can I combine this rule with other technology stacks?

Yes. Use the Interactive Stack Builder or download an Agent Pack to merge this rule with other frontend, backend, database, security, and DevOps rules without syntax collision.

Open Specification · CC BY 4.0·Free for Personal, Team & Commercial In-Repo Use

Citation & Open Source Attribution Guidelines

This specification is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0). You are completely free to adapt and share this rule in your workspace. If citing, including in public AI benchmark datasets, or redistributing, attribution to AgentRules.org is required.

1 Rule in Stack

Nginx