wowprompt

Nginx reverse proxy config with HTTPS and security headers

Writes a complete Nginx server block that puts an app behind HTTPS, redirects HTTP and the www host, passes the right headers to the app, sets security headers and sensible limits, and explains each part. Use it when putting a Node, Python, PHP or Java app behind Nginx on a server.

A full Nginx server block in a code block with comments, the test and reload commands, a table of what each security header does, and a checklist to verify it
The output this prompt produced, unedited.

The prompt

Fill in these first

  • Domain: [e.g. example.com]
  • Redirect www to the bare domain, or the other way: [choose one]
  • App address: [e.g. 127.0.0.1:3000]
  • Certificate paths: [e.g. issued by a free certificate tool, paths if known]
  • Static folder served by Nginx directly, if any: [e.g. /var/www/app/public at /assets/]
  • Largest upload the app accepts: [e.g. 10 MB]
  • WebSockets used: [yes or no]
  • Behind a CDN or load balancer: [yes, name the type, or no]

Task

Write the Nginx configuration for this app and explain it.

Output format

  1. One complete config file in a code block, with a short comment above each block.
  2. It must include: an HTTP to HTTPS redirect, the www redirect chosen, TLS 1.2 and 1.3 only, proxy headers for host, real IP and protocol, timeouts, the upload limit, gzip for text types, and WebSocket upgrade headers only if WebSockets are used.
  3. Security headers: Strict-Transport-Security, X-Content-Type-Options, Referrer-Policy, a frame rule, and a starter Content-Security-Policy marked as needing review.
  4. | Header | What it prevents | Safe starting value |
  5. Commands to test and reload: nginx -t, then a reload, never a restart first.
  6. A five-point check after reload: redirects, certificate, headers, uploads, app logs showing the real client IP.

Rules

  • If behind a CDN, read the client IP only from that CDN's header and trusted ranges, and say so.
  • Do not hide the app port with security through obscurity; bind the app to localhost.
  • Mark anything that depends on the app, such as the Content-Security-Policy, as needing a check.
nginx reverse proxynginx confighttps redirectsecurity headersproxy passserver block

How to run this

Copy the prompt and paste it into Gemini, then set the aspect ratio to 3:4. No reference photo is needed for this one.

The prompt is written in Markdown with each part under its own heading, which is what the copy action hands over. Change one section at a time, keeping the rest intact, so you can tell which change did the work.

Related prompts

All productivity