Linux, Web Server & Database

Configure Nginx Virtual Host

Set up a correctly configured Nginx server block for your domain.

The Problem

Nginx is installed but your domain either shows the default page, the wrong site, or a 404 — because the server block (virtual host) for your specific domain isn't configured, or conflicts with another one already on the server.

About this problem

Nginx uses server blocks to decide which site to serve based on the requested domain name, and getting this wrong — a missing server_name directive, a root pointing at the wrong folder, or two server blocks both claiming default status — is one of the most common reasons a newly pointed domain doesn't show what's expected.

This comes up constantly when adding a new domain to a server that already hosts one or more other sites.

What's Included

What's NOT Included

How It Works

  1. Create a new server block file under sites-available with the correct server_name and document root.
  2. Set up location blocks for static files and PHP processing as the application requires.
  3. Symlink the file into sites-enabled and check for conflicts with existing server blocks (particularly duplicate default_server flags).
  4. Test the configuration with nginx -t before reloading.
  5. Verify the domain serves the correct content and that other sites on the same server remain unaffected.

In practice: you buy the service, send over whatever access or details the job needs, I investigate and do the work, and you confirm it's resolved before we call it done.

Frequently Asked Questions

Why does my new domain show the wrong website?
Usually because another server block on the same server is catching the request first, either through a missing or duplicate server_name directive, or an existing default_server flag taking priority.
What's a server block in Nginx?
It's Nginx's term for what Apache calls a virtual host — a configuration section that defines how requests for a specific domain should be handled, including where to find its files.
Can I host multiple websites on one Nginx server?
Yes, that's exactly what server blocks are for — each domain gets its own block defining its document root and specific configuration, all served from the same Nginx instance.
Why do I get a 404 error even though my files exist?
Often the server block's root path doesn't match where your files actually are, or the location block handling that file type isn't configured correctly.
Do I need a separate server block for www and non-www?
It's common to have one canonical server block and a redirect from the other variant, rather than two full configurations serving the same content independently.
How do I test my Nginx config without breaking the live site?
nginx -t checks the configuration syntax without reloading anything, so you can catch errors before they ever affect the running server.
Please note: the price shown applies to a standard case matching the description above. Every situation is different, and if your request falls outside the normal scope of this service, I will explain this before doing any additional chargeable work. I will never silently turn a small job into an expensive project.
Running into an issue with a service you've already bought, or unsure which one fits your problem? Message me directly on WhatsApp — no ticket system, no bot.