RANA
Nginx Server Block & Vhost Builder

Nginx sites-available Configuration Generator

Generate production-ready Nginx server blocks without SSL. Type your domain, pick your backend type (PHP-FPM, Reverse Proxy, or Static), and copy shell commands to test and reload Nginx instantly.

PHP-FPMArchitecture
80Target Port
64MMax Body Size
58Lines of Conf
Backend Architecture
Includes www. automatically
Absolute path to index files
/etc/nginx/sites-available/example.com.conf
Port 80 (HTTP)

Activate, Test & Reload Nginx

Run these commands on your VPS to link the config, verify Nginx syntax, and safely reload without dropping active traffic.

# 1. Save config to sites-available
sudo nano /etc/nginx/sites-available/example.com.conf

# 2. Enable site by creating a symbolic link in sites-enabled
sudo ln -s /etc/nginx/sites-available/example.com.conf /etc/nginx/sites-enabled/

# 3. Test Nginx syntax configuration (Crucial Step)
sudo nginx -t

# 4. If syntax is OK, reload Nginx without dropping connections
sudo systemctl reload nginx

Understanding Nginx Server Blocks & Activation Workflow

Debian and Ubuntu server distributions organize Nginx using two sibling directories: /etc/nginx/sites-available/ and /etc/nginx/sites-enabled/. The sites-available folder stores the complete configuration file for every site hosted on the machine, while sites-enabled holds symbolic links pointing to the active configurations. This setup lets administrators test or disable sites quickly without deleting configuration files.

Zero-Downtime Reloads

Never restart Nginx abruptly. Using sudo nginx -t confirms all directives and upstream sockets exist. If valid, systemctl reload nginx instructs worker processes to finish in-flight requests while picking up the new configuration seamlessly.

The Path to Free SSL

Starting with an unencrypted port 80 block is recommended before issuing certificates. Once your domain points to your server's IP and serves HTTP traffic, running sudo certbot --nginx -d example.com automatically upgrades this configuration to HTTPS.

Essential Nginx Administration Commands

ActionTerminal CommandExpected Output / Effect
Enable Sitesudo ln -s /etc/nginx/sites-available/app.conf /etc/nginx/sites-enabled/Creates symbolic link to activate configuration.
Test Syntaxsudo nginx -tsyntax is ok & test is successful.
Reload Configsudo systemctl reload nginxApplies changes instantly with zero connection drops.
Disable Sitesudo rm /etc/nginx/sites-enabled/app.confRemoves active link; keeps original file in sites-available.

Frequently Asked Questions

Why start with an HTTP-only config without SSL?

Starting with an active port 80 HTTP server block is the standard prerequisite before obtaining free SSL certificates via Certbot / Let's Encrypt. The ACME HTTP-01 challenge needs a working port 80 block to verify domain control.

How do I test and reload Nginx safely?

Always run sudo nginx -t to check your configuration syntax before restarting. If the test passes with 'syntax is ok', apply changes without dropping active TCP connections using sudo systemctl reload nginx.

Where should this file be saved?

Save the configuration file in /etc/nginx/sites-available/your-domain.conf and symlink it to /etc/nginx/sites-enabled/ using sudo ln -s /etc/nginx/sites-available/your-domain.conf /etc/nginx/sites-enabled/.