Boneyard Tools

Nginx Config Generator

Generate a clean Nginx server block without memorizing the syntax. Pick static, reverse proxy or PHP, set your domain and root or upstream, toggle SSL and gzip, then copy the config into your sites-available folder.

How to generate an Nginx config

  1. Enter your domain and choose a mode: static, reverse proxy or PHP.
  2. Set the document root or upstream target, then toggle SSL, gzip and a max body size.
  3. Copy the output or download nginx.conf into your sites-available folder.

Examples

Reverse proxy to a Node app on port 3000

mode: reverse-proxy, proxyPass: http://localhost:3000, serverName: example.com
server {
    listen 80;
    listen [::]:80;
    server_name example.com;

    location / {
        proxy_pass http://localhost:3000;
        proxy_set_header Host $host;
        ...
    }
}

Static site with HTTPS

mode: static, root: /var/www/html, enableSsl: true, serverName: example.com
server {
    listen 80;
    server_name example.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    ssl_certificate ...;
    root /var/www/html;
    location / {
        try_files $uri $uri/ =404;
    }
}

Frequently asked questions

What is an Nginx server block?

A server block is the part of an Nginx config that defines how to handle requests for one site, including which port and domain to listen on, where files live and how to route or proxy requests. It is the Nginx equivalent of an Apache virtual host.

Where do I put the generated config?

Save it in /etc/nginx/sites-available/ (or /etc/nginx/conf.d/ on some distros) as your-site.conf, symlink it into sites-enabled, then run nginx -t to test and reload Nginx. On many setups the path is /etc/nginx/sites-enabled/your-site.

What is the difference between static, reverse proxy and PHP mode?

Static serves files straight from a document root with try_files. Reverse proxy forwards requests to an upstream app, such as a Node or Python server on localhost, and sets the usual forwarding headers. PHP serves files and passes .php requests to PHP-FPM over a FastCGI socket.

Does the SSL option set up real certificates?

No. It writes the listen 443 ssl lines, ssl_certificate paths and an http to https redirect, but you still need real certificate files. Tools like Certbot can issue free certificates and fill in the correct paths for you.

Will this config work on Apache?

No. The server block syntax is specific to Nginx. Apache uses a different format with VirtualHost and .htaccess. If you are on Apache, generate an .htaccess or virtual host instead.

Is my data sent to a server?

No. The config is generated entirely in your browser from the options you set, so nothing you type is uploaded anywhere.

Related tools