One misplaced semicolon makes Nginx refuse to reload, and one wrong directive can serve the wrong site or leave a hole in your setup. Kwebby's Nginx Config Generator builds a server block from a domain, a document root and a list of options you tick. It handles HTTPS, reverse proxy, PHP-FPM, Gzip, caching, security headers, rate limiting and redirects. You copy the output, test it with nginx -t and reload only when the test passes.
Key Takeaways
- Kwebby's Nginx Config Generator builds a server block from a Domain, Document Root and Port plus options such as HTTPS, reverse proxy, PHP-FPM, Gzip, static file caching, security headers, rate limiting and URL redirects.
- A server block is Nginx's equivalent of an Apache virtual host. It defines how requests for a domain are handled.
- The Reverse Proxy option suits Node.js, Next.js and similar backends, and the PHP-FPM option targets PHP 8.2.
- Nginx's own documentation says
nginx -tchecks the configuration syntax and tries to open the files it refers to, so run it before every reload. - MDN calls the X-XSS-Protection header deprecated and recommends Content-Security-Policy instead.
- Nginx does not read .htaccess files. Use the Nginx generator for Nginx servers and the .htaccess generator for Apache.
What Is the Kwebby Nginx Config Generator?
The Kwebby Nginx Config Generator is a free web tool that builds Nginx server block configuration from a form. You enter a domain, document root and port, tick options such as HTTPS, reverse proxy, PHP-FPM, Gzip and security headers, and copy the generated config. No account is needed.
Nginx is a web server that also works as a reverse proxy and load balancer. Its configuration uses nested blocks: server blocks sit inside http, and location blocks sit inside server. The generator writes those blocks for you so you can focus on choices instead of syntax.
Key Features and How It Works
The Builder tab collects settings and shows the result in a Generated Config panel. Each group of options adds specific directives.
Basic Settings
The Basic section asks for a Domain, a Document Root and a Port. The Port sets the listen port of the server block when HTTPS is off; with HTTPS on, the block listens on 443 and a second block on port 80 redirects to it. The default output uses server_name example.com and root /var/www/html, so you can see where your own values go. The output is a server block only. It does not set worker_connections, keepalive_timeout or client_max_body_size; add those in nginx.conf if you need them.
HTTPS and Redirects
- Force HTTPS + SSL (Let's Encrypt): sets up HTTPS on port 443 and sends HTTP traffic to it. Leave the SSL Paths blank to use
/etc/letsencrypt/live/your-domain/fullchain.pemandprivkey.pem, or type your own paths. The tool does not request a certificate; run Certbot or your host's tool for that. - WWW → non-WWW redirect: makes the non-www hostname the preferred one.
- URL Redirects: click + Add Redirect to map old URLs to new ones.
Reverse Proxy and PHP
- Reverse Proxy (Node/Next.js/etc.): forwards requests to an application server behind Nginx.
- PHP-FPM Support (PHP 8.2): passes PHP requests to PHP-FPM.
Performance
- Gzip Compression: compresses text responses. Gzip and static file caching are ticked by default.
- Static File Caching (1 year): sets
expires 1yfor images, fonts, CSS and JavaScript.
Security
- Security Headers: adds X-Frame-Options, X-Content-Type-Options, Referrer-Policy and Permissions-Policy, plus Strict-Transport-Security when HTTPS is on. It does not add Content-Security-Policy, because a CSP has to match your own scripts and styles.
- Rate Limiting: limits how fast a client can send requests.
AI Generate
An AI Generate tab ("Also Generate with AI") sits next to the Builder for requests you want to describe in words.
Why Careful Nginx Configuration Matters
Nginx configuration is strict, and mistakes show up as outages. A bad directive can return 502 errors, expose files or slow every request. A generator reduces typing errors, but it cannot know your server, so you still need to check the result.
The Nginx beginner's guide explains the safety net. When you reload, the master process checks the new configuration, and if it is invalid, Nginx rolls back and keeps running the old one. The -t switch lets you run the same check without touching the live process.
How to Use the Nginx Config Generator
Creating a config takes six steps.
- Enter your domain. Type the domain name, such as
example.com, in the Domain field. - Set the document root and port. Fill in the Document Root (the folder that holds your site files) and the Port to match your setup.
- Tick your options. Choose from HTTPS, WWW redirect, Gzip, static file caching, reverse proxy, PHP-FPM, security headers and rate limiting.
- Add redirects if needed. Click + Add Redirect and enter the old and new URLs.
- Review and copy. Read the Generated Config panel, check every path and click Copy.
- Test and reload. Save the block in your Nginx configuration, run
nginx -t, and reload withnginx -s reloadwhen the test passes.
Best Practices for Nginx Configuration
Good Nginx changes are small and tested. These habits prevent most outages.
Test Before You Reload
Run nginx -t after every edit. Nginx's command-line switches describe it as a check of the configuration for correct syntax that also tries to open the files the configuration refers to. A failed test costs nothing, and it catches typos before they reach your visitors.
Get the Certificate in Place First
HTTPS needs a certificate and a key. The Nginx guide to configuring HTTPS servers shows the core directives: listen 443 ssl, ssl_certificate and ssl_certificate_key. Issue the certificate first, check that the paths in the generated block match where it lives, and then reload. Afterward, verify the result with the SSL Checker.
Redirect HTTP to HTTPS With a 301
Keep a port 80 server that sends visitors to the HTTPS address with a permanent redirect. Then trace the path with the WWW Redirect Checker to confirm there is one hop and no loop.
Place the Block in the Right Context
A server block belongs inside the http context. Put it in your site configuration file or in the directory your main nginx.conf includes, and avoid pasting a whole generated file inside another server block.
Do Not Add X-XSS-Protection by Hand
MDN lists the X-XSS-Protection header as deprecated and non-standard and recommends Content-Security-Policy instead. The generator does not add it.
Tune Rate Limits With Real Traffic
A limit that is too low blocks real visitors, and one that is too high does nothing. Start with a generous value, watch your logs and tighten it step by step.
Keep the Old Config
Copy the working configuration before you change it, or keep it in version control. A saved copy turns a bad change into a two-minute rollback.
Common Use Cases
- Static site. Serve HTML, CSS, JavaScript and images from a document root with caching headers.
- Node.js or Next.js app. Tick Reverse Proxy so Nginx forwards requests to your application.
- PHP site. Tick PHP-FPM Support to pass PHP files to PHP-FPM.
- HTTP to HTTPS move. Force HTTPS and set a preferred hostname.
- Basic hardening. Add security headers and rate limiting to a new server.
Related Kwebby Tools
The Nginx Config Generator belongs to the server utilities in our Developer Tools collection. These tools cover the rest of the job:
- .htaccess Generator builds the Apache equivalent for servers that use .htaccess.
- URL Rewriting Tool generates Apache mod_rewrite rules for clean URLs.
- SSL Checker verifies your certificate after the Nginx setup.
- WWW Redirect Checker tests that your Nginx redirects work.
- Check Gzip Compression confirms that compression is active.
- Get HTTP Headers shows the headers your server really sends.
Frequently Asked Questions (FAQs)
What is Nginx?
Nginx is a high-performance web server that also works as a reverse proxy and load balancer. It serves static files, forwards requests to application servers and handles HTTPS. Its configuration lives in text files made of directives and blocks.
What is a server block in Nginx?
A server block is Nginx's equivalent of an Apache virtual host. It defines how requests for a particular domain are handled, including the root folder, the ports to listen on and the locations inside it. The generator writes one server block for the domain you enter.
How do I set up HTTPS in Nginx?
Listen on port 443 with the ssl parameter and set ssl_certificate and ssl_certificate_key to your certificate and key files. Add a port 80 block with a 301 redirect to the HTTPS address. In the generator, tick Force HTTPS + SSL (Let's Encrypt) and check the certificate paths before you reload.
How do I test an Nginx config before applying it?
Run nginx -t. It checks the configuration for correct syntax and tries to open the files the configuration refers to. When the test passes, apply the change with nginx -s reload.
Can I proxy a Node.js or Next.js app with this generator?
Yes. Tick Reverse Proxy (Node/Next.js/etc.) and fill in your settings. Nginx forwards requests to the backend with the proxy_pass directive. Test the app through Nginx after you reload.
Is the Nginx Config Generator free?
Yes. The tool is free and needs no account. Enter your domain, tick your options and click Copy.
Final Thoughts
A generator saves typing, and a test saves your server. Use the Nginx Config Generator to build the first draft of your server block, read every path in it, run nginx -t and reload only when it passes. Start with a plain server block for one domain, then add HTTPS and security headers once the basics work. If you run Apache instead, open the .htaccess Generator.