Linux Tools

Nginx Config Generator

Generate optimized Nginx server block configurations for common use cases.

Basic Settings

Main hostname for the server block configuration.

Absolute directory path containing your index files.

Server Configuration Type

SSL / HTTPS (TLS)

Performance, Security & Logs

nginx.conf / sites-available

What is the Nginx Config Generator?

The Nginx Config Generator asks you questions about your web application and automatically generates a secure, highly-optimized Nginx server block configuration tailored to your exact needs.

How to Use

  1. Select the type of application you are hosting (Static HTML, Node.js Reverse Proxy, PHP, or SPA).
  2. Enter your Domain Name and the internal Port your app runs on (if applicable).
  3. Toggle settings like HTTPS redirection or aggressive caching.
  4. Review the generated configuration file in the preview window.
  5. Copy the text and paste it into a new file in your `/etc/nginx/sites-available/` directory.

Common Use Cases

  • Deploying a Next.js or Express application using Nginx as a reverse proxy.
  • Hosting a static portfolio website or a React SPA on an inexpensive VPS.
  • Configuring a secure WordPress installation with PHP-FPM and SSL certificates.

Key Benefits

  • Incorporates modern security best practices and HTTP headers automatically.
  • Saves time spent searching StackOverflow for the correct `try_files` syntax.
  • Helps beginners deploy production-ready web servers without deep sysadmin knowledge.

Frequently Asked Questions

What is an Nginx server block?

A server block (equivalent to Apache VirtualHost) defines how Nginx handles requests for a specific domain or IP address and port combination.

Where should I save my Nginx config file?

On Ubuntu/Debian systems, save your file in /etc/nginx/sites-available/yourdomain.com, then create a symlink to it in the /etc/nginx/sites-enabled/ directory.

How do I test my Nginx configuration?

Before restarting the server, always run sudo nginx -t. This command will test your configuration files for syntax errors and prevent your web server from crashing.

How do I restart Nginx to apply changes?

Once the configuration test passes, apply your changes by running sudo systemctl reload nginx. Reloading is safer than restarting because it doesn't drop active connections.

What is a Reverse Proxy?

A reverse proxy accepts incoming web traffic (usually on port 80 or 443) and forwards it to an internal application server (like a Node.js app running on port 3000).

Why do I need try_files for React or Angular apps?

Single Page Applications (SPAs) handle their own routing. The try_files $uri $uri/ /index.html; directive tells Nginx to route all unknown URLs to index.html so the frontend router can take over.

How do I enable HTTPS?

Our generator can output the standard SSL blocks. You will need to provide the paths to your SSL certificates. The easiest way to get free certificates is by using Let's Encrypt's Certbot tool.

What does server_name do?

The server_name directive tells Nginx which domain names (e.g., example.com www.example.com) should be handled by this specific configuration block.

How do I redirect HTTP traffic to HTTPS?

The best practice is to create a separate server block listening on port 80 that simply returns a 301 permanent redirect to the https:// version of your site.

What is PHP-FPM?

Nginx cannot process PHP code natively. PHP-FPM (FastCGI Process Manager) is a separate service that executes PHP. Nginx uses the fastcgi_pass directive to send PHP requests to it.

Discover More Tools

Explore our full collection of free, privacy-first developer and SEO tools.

Browse All 134+ Tools