DEV3 Technologies home

Developer tool

nginx Config Generator

Generate an nginx server block for static sites, single-page apps, PHP-FPM or a reverse proxy, with HTTPS, redirects, gzip, caching and security headers.

Free, no sign-up. Runs in your browser; nothing is uploaded.

Options

nginx server block

The result appears here.

How to use the nginx config generator

Create your server block

  1. Choose the site type: static files, a single-page app, PHP with PHP-FPM, or a reverse proxy to an app server such as Node.
  2. Enter your domain and either the document root or the upstream address.
  3. Switch on the options you want: HTTPS, www redirect, gzip, static caching, security headers and hidden-file blocking.
  4. Copy the file to your server, test it with sudo nginx -t and reload with sudo systemctl reload nginx.

Site types explained

  • Static serves files and returns 404 for anything missing.
  • Single-page app falls back to index.html, so deep links work in React, Vue or Angular builds.
  • PHP sends unknown paths to index.php (the pattern Laravel and WordPress use) and passes .php files to PHP-FPM through the socket you specify.
  • Proxy forwards requests to your app and sets the headers it needs to know the real client address. WebSocket upgrade headers can be added.

Good practice

  • Run nginx -t before every reload. A syntax error then never reaches the live server.
  • Keep HSTS off until HTTPS works on every subdomain you use, because browsers remember it for a year.
  • Set client_max_body_size to the largest upload you accept. The default of 1 MB causes 413 errors on image uploads.
  • Cache static assets for a long time only when the file names change on each release.
  • Deny dot files, but keep .well-known open for certificate renewal.

For the same rules on Apache, use the .htaccess generator on this site.

Frequently asked questions

Where does the generated file go?

On Debian and Ubuntu, save it as /etc/nginx/sites-available/yourdomain, link it into sites-enabled, run nginx -t to check the syntax, then reload nginx. On other systems put it under /etc/nginx/conf.d/ with a .conf extension.

How do I get the SSL certificates?

The defaults point to Let's Encrypt paths. Run certbot first to create the certificates, or enter your own certificate and key paths in the options. Without certificates nginx will refuse to start with the HTTPS block.

What does try_files do for a single-page app?

It serves a real file when one exists and otherwise returns index.html, so client-side routes such as /dashboard load the app instead of a 404.

Why a separate block for the http redirect?

Port 80 only needs to redirect and answer certificate challenges. Keeping it separate is the clearest and cheapest way to do that.

Is the configuration sent anywhere?

No. It is assembled in your browser.