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.
Estimated Time
Use Case
Use this checklist when adding a new domain or hosting multiple websites on the same Nginx VPS.
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