DevTools Logo

NGINX Config Builder

NGINX Config Builder

Generate a correct NGINX server block — reverse proxy, static hosting, SSL and redirects — without hand-writing directives.

Server Settings

Location /

Examples

Build an HTTP reverse proxy

Input
Server name: api.example.com
Listen port: 8080
SSL: off
Client max body size: 2M
Location: / (reverse proxy)
Upstream: http://127.0.0.1:3000
Output
server {
    listen 8080;
    listen [::]:8080;
    server_name api.example.com;
    client_max_body_size 2M;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

A proxy location includes the upstream plus Host, client-IP, forwarded-chain, and original-scheme headers.

Serve an HTTPS single-page application

Input
Server name: app.example.com
SSL: on
Redirect HTTP to HTTPS: on
Certificate: /etc/letsencrypt/live/app.example.com/fullchain.pem
Key: /etc/letsencrypt/live/app.example.com/privkey.pem
Location: / (static files)
Root: /srv/app
SPA fallback: on
Output
server {
    listen 80;
    server_name app.example.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    server_name app.example.com;
    ssl_certificate /etc/letsencrypt/live/app.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/app.example.com/privkey.pem;

    location / {
        root /srv/app;
        try_files $uri $uri/ /index.html;
    }
}

Enabling both SSL and HTTP redirect emits two server blocks, while SPA fallback sends unmatched static paths to index.html.

About this tool

NGINX configuration is powerful but unforgiving: directives must sit in the right context, proxy setups need the right forwarded headers to avoid broken client IPs and redirect loops, and a missing try_files line is the classic reason a single-page app 404s on refresh. This builder assembles a correct server block from a form so you get the boilerplate right.

Add location blocks of three kinds — a reverse proxy (with Host and X-Forwarded-* headers pre-filled), static hosting from a document root (with an optional SPA fallback to index.html), or a redirect with your chosen status code. Turn on SSL to emit listen 443 ssl with your certificate paths, and enable HTTP-to-HTTPS to generate a companion port-80 server that permanently redirects. Optional gzip and client_max_body_size round out the common cases. Everything runs in your browser.

How to use

  1. Set the server basics

    Enter the server name (domain) and listen port, or enable SSL to switch to 443.

  2. Add location blocks

    Choose reverse proxy, static files or redirect for each path and fill in the target.

  3. Enable SSL and redirects

    Turn on SSL with your cert/key paths and add an HTTP→HTTPS redirect if needed.

  4. Copy the config

    Copy the generated server block into sites-available and reload NGINX.

Use cases

Reverse-proxying an application server

Generate the common proxy_pass and forwarded-header boilerplate for a Node.js, Python, or other local upstream.

Hosting a static SPA

Create a document-root location with index.html fallback so client-side routes survive a browser refresh.

Bootstrapping TLS server blocks

Add certificate paths, IPv4 and IPv6 port 443 listeners, and an optional companion HTTP-to-HTTPS redirect.

Combining path behaviors

Assemble multiple proxy, static, and redirect locations in one generated server block.

Location types

TypeGenerates
Reverse proxyproxy_pass + Host / X-Real-IP / X-Forwarded-For / X-Forwarded-Proto
Static filesroot + try_files (with optional SPA fallback to index.html)
Redirectreturn <code> <target>;
SSLlisten 443 ssl + ssl_certificate / ssl_certificate_key
HTTP→HTTPSA port-80 server that 301-redirects to HTTPS

Config is generated client-side — nothing is uploaded.

Common mistakes

Mistake:Deploying the generated text without testing the complete NGINX configuration.

Fix:Place it in the intended context and run nginx -t before reloading. The builder renders form values but does not invoke NGINX or validate the surrounding configuration.

Mistake:Enabling SSL and assuming the named certificate and private-key files already exist and match.

Fix:Provision the certificate separately, verify both paths and permissions on the server, and confirm the certificate covers the configured server name.

Mistake:Pasting untrusted text into directive fields and treating the output as sanitized.

Fix:Review every domain, path, upstream, redirect, size, and status value. The builder trims and interpolates strings; it does not escape arbitrary NGINX syntax.

Mistake:Ignoring URI-joining behavior when changing proxy_pass or location paths.

Fix:Check the upstream URI and trailing slashes against the routing behavior you need, then test representative requests before deployment.

Frequently asked questions

References & standards