Skip to main content
Back to Dev generators

Dev

Generator für Nginx-Location-Blöcke

Used by developers, writers, and creators worldwide.

An nginx location block generator gives you one correct location block for a specific routing task, so you can drop it into an existing server block without rebuilding the whole config. Pick the task — proxy to a backend, serve static files, apply an API rate limit, deny a path, or upgrade a WebSocket connection — and set the URL path, and it returns the block with exactly the directives that task needs, like the upgrade headers a WebSocket requires or the burst setting a rate limit uses. Sysadmins use it to add a route, recall the WebSocket proxy headers, or lock down a path. It runs in the browser and generates instantly. Paste the block inside your server block, change the proxy target and paths, then validate with nginx -t before reloading. Each block captures a known-good pattern so the route behaves the way you expect.

Read the complete guide — 5 min read

Loading usage…

Free forever — no account required

How to use

  1. Choose your options above
  2. Click Generate
  3. Copy your result

Detailed instructions

  1. Pick the location task.
  2. Enter the URL path it should match.
  3. Click Generate to produce the location block.
  4. Paste it into your server block and run nginx -t.

Use Cases

  • Adding a proxy route to an existing nginx server block
  • Serving a static directory with caching headers
  • Applying a rate limit to an API path
  • Denying access to a sensitive path
  • Recalling the headers a WebSocket upgrade needs

Tips

  • Validate with nginx -t before every reload to catch typos.
  • Use alias for a directory mapping and root for a path prefix.
  • Set a long proxy_read_timeout for WebSocket connections.
  • Put the rate-limit zone in the http block, not the location.

FAQ

where do I put this block

Paste it inside an existing server block in your nginx config. A location block only makes sense within a server context, so it slots in next to your other locations and shares the server name and TLS settings.

why does WebSocket need special headers

A WebSocket starts as an HTTP request that asks to upgrade the connection. Forwarding the Upgrade and Connection headers and using HTTP 1.1 lets nginx pass that handshake through to the backend instead of treating it as a normal request.

why is the rate limit zone outside the block

The limit_req_zone directive must live in the http context, not inside a location, so the generator shows it as a comment to add there. The location then references that zone with limit_req, which is how nginx ties the two together.

You might also like

Popular tools from other categories that share themes with this one.