What is the Nginx config generator?

This free tool builds a complete, commented nginx.conf and the matching site files for you. Choose your domain, PHP or Python backend, HTTPS and HTTP/2, caching, compression, security headers and logging, then download the files or copy them. You start from a safe, fast baseline instead of a blank file. It is based on the open-source nginxconfig.io project.

How to use the Nginx config generator

  1. Enter your domain name and the root path of your site.
  2. Pick your stack: PHP-FPM, WordPress, Python, a reverse proxy or a plain static site.
  3. Turn on HTTPS (Let's Encrypt or your own certificate) and HTTP/2.
  4. Enable security headers, gzip or Brotli, rate limiting and expiry by file type as needed.
  5. Download the files, copy them into place, then test and reload (see below).

Where is the Nginx config file located?

SystemMain fileSite configs
Debian / Ubuntu/etc/nginx/nginx.conf/etc/nginx/sites-available/ (symlinked into sites-enabled/)
RHEL / Rocky / AlmaLinux/etc/nginx/nginx.conf/etc/nginx/conf.d/*.conf
Docker (official image)/etc/nginx/nginx.conf/etc/nginx/conf.d/
macOS (Homebrew, Apple silicon)/opt/homebrew/etc/nginx/nginx.conf/opt/homebrew/etc/nginx/servers/

Not sure which file your server uses? Ask Nginx itself:

nginx -T 2>/dev/null | head -5
nginx -V 2>&1 | tr ' ' '\n' | grep conf-path

Test and apply your Nginx configuration

sudo nginx -t                  # syntax check; prints the file and line of any error
sudo systemctl reload nginx    # apply without dropping connections
sudo tail -f /var/log/nginx/error.log

nginx -t doubles as a config checker: run it after every change and before every reload.

Nginx config examples you can copy

Redirect HTTP to HTTPS and www to non-www

server {
    listen 80;
    server_name example.com www.example.com;
    return 301 https://example.com$request_uri;
}
server {
    listen 443 ssl;
    http2 on;
    server_name www.example.com;
    ssl_certificate     /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    return 301 https://example.com$request_uri;
}

http2 on; needs Nginx 1.25.1 or newer. On older versions write listen 443 ssl http2; instead.

PHP-FPM (WordPress-style) location blocks

location / {
    try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
    include fastcgi_params;
    fastcgi_pass unix:/run/php/php8.3-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ /\.(?!well-known) { deny all; }

Reverse proxy to an app on port 3000

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;
}

Step by step with TLS and firewall: complete guide to building a secure Nginx reverse proxy. Performance settings: mastering Nginx configurations for optimal web server performance.

Run Nginx on your own server

Nginx runs well on a small VPS. Try it on a Serverion VPS from €5 per month, or take a dedicated server from €40 per month for busy sites.

Nginx config generator FAQ

What is an Nginx config generator?

A tool that builds the nginx.conf and site files from your choices (domain, PHP or Python backend, HTTPS, caching, security headers) so you do not write them by hand.

Is this Nginx config generator free?

Yes. It is free to use and needs no sign-up. It is based on the open-source nginxconfig.io project; the credits are in the footer of the tool.

Where do I put the generated config?

Copy the files into /etc/nginx/ as shown by the tool (see the table above for other systems), then run nginx -t and reload Nginx.

How do I check my Nginx config for errors?

Run sudo nginx -t. It reports the file and line number of any syntax problem and does not touch the running server.

Does the generator support WordPress, PHP and Node.js?

It has presets for WordPress, Drupal and Magento, PHP-FPM and Python (uWSGI) backends, and a reverse proxy option for Node.js or any other backend.

Does it support PHP 8?

The PHP socket presets in the tool stop at PHP 7.3. For PHP 8, change the fastcgi_pass line in the generated php_fastcgi.conf to your PHP 8 socket, for example /run/php/php8.3-fpm.sock.

Does it set up HTTPS and HTTP/2?

Yes. The site options include HTTPS with Let's Encrypt or your own certificate, HTTP/2 and HSTS.

Is the generated configuration secure?

It includes security headers and sensible defaults, but always review it and test on a staging server before production.