October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk10 min

How to Set Up Separate NGINX Config Files for Multiple Sites

Create one NGINX server block per site, load the files through the active nginx.conf, enable them with Debian-style symlinks or conf.d includes, then test and reload safely.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The reliable pattern is one server { ... } block per website, stored in its own file and loaded by the running nginx.conf. Ubuntu and Debian packages normally use /etc/nginx/sites-available/ for source files and symlinks in /etc/nginx/sites-enabled/ to turn sites on. Other installations commonly load separate *.conf files from /etc/nginx/conf.d/ through an include directive inside the http block.

After creating or changing a site file, verify that the file is actually included, give the site an appropriate server_name and listen configuration, run sudo nginx -t, and reload NGINX. A reload applies valid changes without stopping the service.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What separate NGINX files actually do

NGINX does not discover a configuration file merely because it exists in a familiar directory. The effective configuration starts with the main file, usually called nginx.conf, and follows every include directive it contains. Splitting sites into separate files is therefore an organizational and operational choice; the files become active only when the running configuration includes them.

For HTTP traffic, the top-level http { ... } context contains one or more server { ... } blocks. Each server block describes a virtual host: which address or port it listens on, which host names it answers, where its content is located, and how request paths are handled. A location { ... } block belongs inside a server block and controls URI-specific behavior.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

This hierarchy matters when you edit files. A HTTP server block cannot be placed directly at the top level, and an include intended to load HTTP server blocks must be inside http { ... }. NGINX also has separate top-level contexts such as events, mail, and stream; files containing HTTP virtual hosts should not be included in those contexts.

Choose the layout used by your installation

Use the convention supplied by your operating-system package or build. The directory names are not interchangeable unless the main configuration explicitly includes them.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Layout Where a site file lives How it is enabled Best fit Disabling one site
Ubuntu/Debian package convention /etc/nginx/sites-available/<site-name> Create a symlink with the same name in /etc/nginx/sites-enabled/ Packaged Ubuntu or Debian servers following their documented multi-site workflow Remove the enablement symlink; keep the source file intact
Include-based convention Often /etc/nginx/conf.d/<site-name>.conf The main file includes a wildcard such as /etc/nginx/conf.d/*.conf Upstream NGINX installations and distributions that provide a conf.d include Move or rename the file so it no longer matches the include, or remove its include line

Ubuntu Server documentation describes sites-available and sites-enabled as the directories for multiple websites. Debian documentation describes files in sites-enabled as symlinks to files in sites-available, and treats conf.d/*.conf as an additional configuration directory. F5 NGINX documentation describes splitting configuration into feature-specific files in /etc/nginx/conf.d and loading them with include.

Check the active configuration before adding a site

Do not assume that the path on one server matches the path on another. First identify the binary and configuration path used by the running installation:

  1. Run nginx -V and note the compiled configuration path reported by the build.
  2. Open that main configuration file and locate the http { ... } block.
  3. Look for an existing include matching sites-enabled, conf.d, or another directory.
  4. Use sudo nginx -T when you need to see the complete, merged configuration, including files pulled in by every include. This is the authoritative view for diagnosing ordering, duplicate names, and unexpected defaults.

If no include loads the directory you plan to use, either place the file in a directory already included by the configuration or add an appropriate include in the http context. An unused file in /etc/nginx/sites-available or /etc/nginx/conf.d has no effect.

Set up a site on Ubuntu or Debian

1. Create the document root

Choose a separate directory for the site’s files. For example, create /srv/example.test/html and put the site’s index.html and other assets there. Keeping roots separate prevents one virtual host from accidentally serving another site’s files and makes backups or removal more predictable.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

2. Write one complete server block

Create /etc/nginx/sites-available/example.test with a complete HTTP server block:

server {
    listen 80;
    listen [::]:80;
    server_name example.test www.example.test;

    root /srv/example.test/html;
    index index.html;

    location / {
        try_files $uri $uri/ =404;
    }
}

The two listen directives cover IPv4 and IPv6 on port 80. The server_name line lists the host names this block should answer. The root and index directives define the document root and default file, while try_files serves an existing path and returns HTTP 404 when neither the requested file nor directory exists.

Use a filename that identifies the site, but remember that the filename itself does not determine request routing. NGINX uses the directives inside the file after it has been included.

3. Enable the file with a symlink

On the Ubuntu/Debian layout, enable the source file without copying it:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo ln -s /etc/nginx/sites-available/example.test /etc/nginx/sites-enabled/example.test

The symlink is the enablement switch. Editing the file in sites-available changes the same file that the enabled link loads, so you retain one source of truth.

4. Decide what to do with the packaged default site

A newly installed package may have a default-site symlink that answers requests not matched by your intended host names. If that behavior is undesirable, inspect the default file and remove only its enablement symlink:

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
sudo rm /etc/nginx/sites-enabled/default

Do this only after checking the consequences. The default server can be useful as a deliberate catch-all, diagnostic response, or temporary landing page. Removing it is not required for every multi-site setup.

5. Validate and reload

After creating the file or symlink, validate the complete configuration:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo nginx -t

Proceed only when the test reports a successful syntax check. Then apply the change with a graceful reload:

sudo systemctl reload nginx

A reload keeps the service running while workers adopt the validated configuration. If the test fails, correct the reported file and line instead of reloading a broken configuration.

Add a second and third site

Repeat the same pattern for each additional domain: create a separate document root, create a separate file in sites-available, give it the correct server_name values and root, create its enablement symlink, test, and reload. Each file can contain several related host names, such as a bare domain and its www name, but unrelated sites should not share a server block unless you intentionally want identical behavior.

Multiple domains commonly share port 80 or port 443. NGINX can distinguish them by the Host header when their server_name values are different. The Ubuntu example also demonstrates distinct listen ports when that is the chosen design. A different port is not inherently required for every domain; the address, port, and host-name combination must match the traffic you expect and the syntax supported by the installed package.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

For a second site, for example, create /etc/nginx/sites-available/second.example with its own server_name second.example and root such as /srv/second.example/html, then enable it with a matching symlink. Do not edit the main nginx.conf for every new site when the package already includes sites-enabled/*; the symlink is the intended per-site switch.

Use the conf.d layout on other installations

Some installations do not provide the Debian-style directories. Check the active configuration path with nginx -V, open the reported nginx.conf, and confirm that its http block contains an include such as:

include /etc/nginx/conf.d/*.conf;

The include must be inside http { ... } when the files contain HTTP server blocks. Do not place this include at the top level or inside events { ... }.

Create a file such as /etc/nginx/conf.d/example.test.conf containing the same complete server block shown earlier. The .conf suffix matters when the wildcard includes only files ending in that suffix. Once the file exists, run the configuration test and reload commands described above. If the test succeeds but the site is not active, inspect the merged output from sudo nginx -T to confirm that the file was read.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To disable this style of site temporarily, remove or rename the file so it no longer matches the wildcard, then test and reload. Keeping the file under version control or renaming it is safer than deleting configuration you may need again.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Understand how NGINX chooses a server block

When a request arrives, NGINX first considers the local address and port selected by the listen directives. For HTTP requests that include a host name, it then compares the request’s Host header with the server_name values available on that address and port. A request whose DNS name points to your server can still reach the wrong site if the host header does not match, if another block is the default for that listener, or if the desired file was never included.

A default_server designation or an enabled packaged default site can therefore catch requests that do not match your names. Check for those definitions in the merged configuration rather than guessing from filenames. Distinct server_name values are normally sufficient for several domains on the same HTTP port; separate ports are useful when you intentionally expose different services or follow a package’s example requiring them.

DNS is a separate dependency. The domain’s records must point to the server’s address before an ordinary browser request can reach the intended block. Testing locally with a request that supplies the correct host header can help distinguish DNS problems from NGINX routing problems.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Validate every change before it reaches users

Use this sequence whenever you add, remove, or edit a site:

  1. Confirm the file is located in a directory that the active nginx.conf actually includes.
  2. Check that the server block is inside an HTTP include and that braces are balanced.
  3. Verify the spelling of every server_name, the intended listen address and port, and the document-root path.
  4. Run sudo nginx -t and fix every reported error.
  5. Run sudo nginx -T if the syntax test passes but ordering, duplicate definitions, or an unexpected default remains unclear.
  6. Reload with sudo systemctl reload nginx only after validation succeeds.
  7. Make a request using the exact domain name and inspect the response. If it still reaches another site, continue with the routing checks below.

Troubleshoot the common failure modes

The new site always shows the default page

  • Check that the enablement symlink exists and points to the intended file.
  • Use sudo nginx -T to prove that the server block is present in the effective configuration.
  • Confirm that the browser request’s host name exactly matches a server_name in that block.
  • Look for an unintended default_server or an enabled default-site symlink.
  • Verify that DNS for the domain points to this NGINX host rather than another address.

NGINX refuses to reload

  • Run sudo nginx -t directly and read the file name and line number in the error.
  • Check for a missing semicolon, unmatched brace, invalid directive context, or a path typo.
  • Ensure that a file included from http contains HTTP directives rather than directives intended for another context.
  • Do not remove working configuration to silence an error; correct the reported file, test again, and reload only after a successful result.

The test passes but the response is wrong

  • Print the merged configuration with sudo nginx -T and look for duplicate server_name entries on the same listener.
  • Check whether the request uses IPv4 or IPv6 and whether both corresponding listen directives are configured as intended.
  • Confirm that the requested URL maps beneath the configured root and that the expected index file exists.
  • Inspect NGINX’s error log and the service logs for permission, file-not-found, or upstream errors after routing has been verified.

Disabling a site has no visible effect

  • On Ubuntu/Debian, remove the symlink in sites-enabled, not the source file in sites-available, then test and reload.
  • On a conf.d layout, make sure the renamed file no longer matches the configured wildcard.
  • Check nginx -T after reloading to ensure no second copy of the same server block remains enabled.

Organize files for long-term maintenance

Give files stable, recognizable names based on the domain or service they configure. Keep one site’s root, host names, locations, and related directives together unless a deliberate shared include improves consistency. When you do use shared snippets, verify their context: a snippet containing location directives belongs inside a server block, while a snippet containing server blocks belongs inside http.

Use the source-file-plus-enable-link model to separate configuration from activation. It lets you prepare a site without serving it, disable a site without losing its settings, and review the exact set of active links. In a conf.d layout, the equivalent is a clearly named file whose presence in the wildcard directory is the enablement decision.

Keep a record of which host names, addresses, ports, and document roots belong together. This is especially useful when several domains share port 80 or 443, because a typo in one server_name can send requests to a different matching or default block. Always make the configuration test part of the change procedure, not an optional check after a failed reload.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Layout decision at a glance

Question Use sites-available/sites-enabled Use conf.d
Does the package already include sites-enabled/*? Yes; follow that convention. Only if a separate conf.d/*.conf include is active.
How is a site enabled? Create a symlink from sites-enabled to sites-available. Place a matching *.conf file in the included directory.
How is a site disabled while retaining its source? Remove its enablement symlink. Rename or move the file so it no longer matches the include.
What is portable across installations? The virtual-host pattern and validation steps, not the directory names. The virtual-host pattern and validation steps, not the directory names.

The portable principle is simple: one independently identifiable server block per site, an explicit include path, matching host and listener settings, a successful configuration test, and a reload. The directory convention is packaging policy layered on top of that principle.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.