Nginx Server Block Checklist for Multiple Websites
When you host multiple websites on one VPS, Nginx server blocks decide which domain points to which website directory. A small mistake in server_name, root path or SSL config can cause wrong website loading, 404 errors or redirect problems.
What this checklist covers
- Domain mapping
- Server block file
- Root directory
- Index file
- SSL config
- Redirect rules
- Config testing
Checklist
- Create a separate website directory for each domain.
- Create a separate Nginx server block file for each domain.
- Set the correct server_name.
- Set the correct root path.
- Set index files correctly.
- Enable the site using a symlink if using sites-available and sites-enabled.
- Run nginx -t before reload.
- Install SSL for the correct domain.
- Check www and non-www behavior.
- Test each domain separately in browser.
Final check
Each domain should load its own website, use the correct SSL certificate and redirect consistently to the final preferred URL.
When to Use This Checklist
Use this checklist when adding a new domain or hosting multiple websites on the same Nginx VPS.
Required Tools
SSH access, Nginx, domain DNS access, website root path, Certbot, text editor
Before You Start
Prepare the domain, website directory and preferred URL format before editing Nginx config.
Structured Checklist Steps
- Create website directory.
- Create server block file.
- Set server_name.
- Set root path.
- Set index directive.
- Enable site symlink.
- Run nginx -t.
- Reload Nginx.
- Install SSL.
- Test domain and redirects.
Verification Steps
- nginx -t passes.
- Domain loads correct website.
- SSL certificate matches domain.
- www and non-www behavior is correct.
- No wrong site appears.
Rollback Plan
If a new server block breaks Nginx, remove the symlink from sites-enabled or restore the previous config file, then test and reload Nginx.
Common Mistakes
- Wrong root path.
- Missing server_name.
- Forgetting to enable the site.
- Reloading Nginx before nginx -t.
- Mixing SSL configs between domains.
Related Commands
sudo nano /etc/nginx/sites-available/example.com
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
sudo certbot --nginx -d example.com -d www.example.com