Nginx Config Generator
Answer a few questions about your site and get a complete Nginx server block: HTTP to HTTPS redirect, www handling, the right location blocks for static files, PHP or a proxied app, and sensible performance and security settings. Installation commands are included.
- Runs in your browser
- No sign-up
- Free to use
How to install it
How to use Nginx Config Generator
- Enter your domain and choose how www should be handled.
- Select what the site runs and fill in the document root, PHP-FPM socket or app address.
- Choose the HTTPS setup and tick the options you want.
- Download the file and follow the installation steps shown next to it.
Nginx Config Generator features
Four site types
Static files, single-page apps, PHP through PHP-FPM, and a reverse proxy for Node.js, Python or any other app server.
HTTPS done properly
Port 80 redirects to HTTPS, one canonical host name, modern TLS versions, optional HSTS and HTTP/2.
Let's Encrypt ready
Uses Certbot's certificate paths and keeps the ACME challenge location open.
Safe PHP handling
Runs only PHP files that exist, which closes a well-known way of executing uploaded files.
Proxy headers and WebSockets
Forwards host, client address and protocol, with optional upgrade headers.
Install instructions
Where to save the file, how to enable and test it, and how to reload Nginx.
When to use Nginx Config Generator
- Putting a Node.js or Python app behind Nginx on a VPS.
- Hosting a Laravel or WordPress site with PHP-FPM.
- Serving a React, Vue or Angular build with client-side routing.
- Adding HTTPS and a clean redirect setup to an existing site.
Nginx Config Generator FAQ
Where does the file go?
On Debian and Ubuntu, in /etc/nginx/sites-available/, with a symbolic link in /etc/nginx/sites-enabled/. On other systems, in /etc/nginx/conf.d/ with a .conf extension. Then run nginx -t to test and systemctl reload nginx to apply.
Nginx fails to start because the certificate is missing. What do I do?
The HTTPS block refers to certificate files, and Nginx will not load a configuration whose files do not exist. Obtain the certificate first. The simplest route is to start with “HTTP only”, run certbot --nginx, and let Certbot add the HTTPS parts; or request the certificate with certbot certonly and then install the full file.
Why do my routes return 404 in a single-page app?
A URL such as /dashboard exists only inside the JavaScript app, not as a file. The server has to answer every unknown path with index.html, which is what try_files $uri $uri/ /index.html does. Choose “Single-page app” as the site type.
What is try_files?
It tells Nginx what to try, in order: the exact file, then a folder of that name, then a fallback. For PHP applications the fallback is /index.php with the query string, which is how frameworks receive all requests that are not static files.
Does it replace .htaccess?
Yes. Nginx does not read .htaccess files. Rules such as redirects and front-controller rewrites have to be expressed in the server block, as this generator does.
Is the generated configuration production-ready?
It is a sound baseline that follows current practice. Review it for your case: upload size, timeouts for slow endpoints, rate limiting, and a Content-Security-Policy are application-specific and are not guessed.
How Nginx decides what to serve
An Nginx configuration is organised into server blocks, one per site or host name. When a request arrives, Nginx first picks the server block by the port it came in on and the host name in the request. Inside that block, it picks one location block by matching the path. Almost every configuration question comes down to these two selections.
Redirects are best written as separate, tiny server blocks. One listens on port 80 for all names and sends everything to HTTPS. Another catches the host name you do not want, with or without www, and sends it to the one you do. The main block then has a single job. This is clearer and faster than conditional logic inside one block, and it guarantees that every visitor and every search engine ends up on exactly one address.
Location matching has rules worth knowing. Exact matches win first. Then the longest matching prefix is remembered, regular-expression locations are tried in the order they appear, and the first that matches wins over the remembered prefix. That is why the block for .php files, a regular expression, takes precedence over the general “/” block. Within a location, directives such as try_files and proxy_pass decide what happens to the request.
As a reverse proxy, Nginx accepts the connection from the visitor, handles TLS, compression and slow clients, and passes a plain HTTP request to an application on the same machine. The application no longer sees the visitor directly, so Nginx forwards the original host, address and protocol in headers. Applications must be told to trust these headers, otherwise they generate links with the wrong scheme or log the proxy's address for every visitor.