Skip to main content
Dev · 283 tools

Mock Nginx Config Generator

Generates example nginx server block configurations for testing

Nginx ConfigExample — click Generate for yours
# checkout.mysite.test — example server block (generated, not for production) upstream tickets_prod { server 127.0.0.1:5000 max_fails=5 fail_timeout=30s; server 127.0.0.1:5001 max_fails=5 fail_timeout=30s; keepalive 32; } server { listen 80; listen [::]:80; server_name checkout.mysite.test www.checkout.mysite.test; client_max_body_size 10m; access_log /var/log/nginx/checkout.mysite.test.access.log; error_log /var/log/nginx/checkout.mysite.test.error.log warn; location / { proxy_pass http://tickets_prod; proxy_http_version 1.1; proxy_set_header Connection ""; 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; } location /static/ { alias /opt/tickets/release/static/; expires 30d; access_log off; } location = /healthz { access_log off; return 200 'ok'; } }

Generated 84 words · 1,049 characters

See 3 examples
  • Example 1
    # checkout.mysite.test — example server block (generated, not for production)
    upstream tickets_prod {
        server 127.0.0.1:5000 max_fails=5 fail_timeout=30s;
        server 127.0.0.1:5001 max_fails=5 fail_timeout=30s;
        keepalive 32;
    }
    
    server {
        listen 80;
        listen [::]:80;
        server_name checkout.mysite.test www.checkout.mysite.test;
        client_max_body_size 10m;
    
        access_log /var/log/nginx/checkout.mysite.test.access.log;
        error_log  /var/log/nginx/checkout.mysite.test.error.log warn;
    
        location / {
            proxy_pass http://tickets_prod;
            proxy_http_version 1.1;
            proxy_set_header Connection "";
            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;
        }
    
        location /static/ {
            alias /opt/tickets/release/static/;
            expires 30d;
            access_log off;
        }
    
        location = /healthz {
            access_log off;
            return 200 'ok';
        }
    }
  • Example 2
    # news.corp.example — example server block (generated, not for production)
    upstream partners_backend {
        server 127.0.0.1:9090 max_fails=1 fail_timeout=30s;
        keepalive 32;
    }
    
    server {
        listen 80;
        listen [::]:80;
        server_name news.corp.example www.news.corp.example;
        client_max_body_size 10m;
    
        access_log /var/log/nginx/news.corp.example.access.log;
        error_log  /var/log/nginx/news.corp.example.error.log warn;
    
        location / {
            proxy_pass http://partners_backend;
            proxy_http_version 1.1;
            proxy_set_header Connection "";
            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;
        }
    
        location /static/ {
            alias /var/lib/partners/www/static/;
            expires 30d;
            access_log off;
        }
    
        location = /healthz {
            access_log off;
            return 200 'ok';
        }
    }
  • Example 3
    # wiki.demo.test — example server block (generated, not for production)
    upstream search_nodes {
        server 127.0.0.1:8088 max_fails=1 fail_timeout=15s;
        server 127.0.0.1:8089 max_fails=1 fail_timeout=15s;
        keepalive 32;
    }
    
    server {
        listen 80;
        listen [::]:80;
        server_name wiki.demo.test www.wiki.demo.test;
        client_max_body_size 10m;
    
        access_log /var/log/nginx/wiki.demo.test.access.log;
        error_log  /var/log/nginx/wiki.demo.test.error.log error;
    
        location / {
            proxy_pass http://search_nodes;
            proxy_http_version 1.1;
            proxy_set_header Connection "";
            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;
        }
    
        location /static/ {
            alias /usr/share/nginx/search/static/;
            expires 30d;
            access_log off;
        }
    
        location = /healthz {
            access_log off;
            return 200 'ok';
        }
    }

About this generator

Nginx server block syntax trips up developers who mostly work in application code. The block-and-directive structure, the proxy header conventions, and the static-file location all need to be right for the config to load correctly. This tool generates a sample nginx server block — no inputs required — that includes an upstream block, listen directives for IPv4 and IPv6, a server_name with both bare and www variants, a reverse-proxy location, a static-file location with a 30-day cache expiry, and a /healthz endpoint. Each run builds a different config: the domain combines one of about 40 subdomains with a reserved example or .test domain, the upstream is named after one of 40 app names and points at one or two local ports chosen from 20 common ones (3000, 5173, 8080, 9000 and so on), and the static location aliases one of 15 typical deploy paths such as /var/www/shop/static/. The proxy location sets Host, X-Real-IP, X-Forwarded-For and X-Forwarded-Proto, which is the standard proxy setup, and the static location adds a 30-day expires directive. Copy the output into a new server block file, then replace the domain and proxy port with your own values. Always validate the config with nginx -t before reloading on a live server — a syntax error prevents nginx from starting and will take your site down until you fix it.

How to use

  1. Click Generate to produce an nginx config.
  2. Copy it into a server block file.
  3. Adapt the domain, port, and paths.
  4. Test the config before reloading.

Use Cases

  • •Learning nginx configuration
  • •Documenting a server setup
  • •Demoing a reverse proxy
  • •Seeding example config
  • •Testing a config parser

Tips

  • →proxy_pass forwards to your app.
  • →Serve static files separately.
  • →Always test config before reloading.
  • →Adapt the domain and ports.

FAQ

what does the generated nginx config include

An upstream block pointing at one or two local app ports, a server block listening on port 80 (IPv4 and IPv6), a server_name covering both bare and www domains, per-domain access and error logs, a root location that proxies to the upstream with Host, X-Real-IP and forwarding headers, a /static/ location that serves files from a deploy path with a 30-day expires, and a /healthz location that returns 200. TLS is not included.

what does proxy_pass do and why does it matter

proxy_pass forwards incoming requests to another server — typically your app running on a local port like 3000. Nginx acts as a reverse proxy, handling concerns like TLS termination, header forwarding, and static file serving, while your app focuses on dynamic responses.

does the generator produce TLS or HTTPS configuration

No. The generated config only covers HTTP on port 80. For TLS, you would add a second server block listening on port 443 with ssl_certificate and ssl_certificate_key directives, or use a tool like Certbot to generate and insert those blocks automatically.

how do I test a config before reloading nginx

Run nginx -t (or nginx -T to also print the expanded config). This validates the syntax without actually reloading the server. Only run nginx -s reload after -t exits cleanly — a config error during reload prevents nginx from starting and can take your site offline.

You might also like

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