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

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Give each subdomain its own Nginx server block, set an exact server_name, and assign a different root. DNS must send every hostname to the Nginx server; Nginx then uses the request’s Host header to choose the matching block. The request URI is appended to that block’s root, so app.example.com/images/logo.png can map to /var/www/app.example.com/public/images/logo.png while the blog hostname maps to a different directory.

How the mapping works

Three layers must agree:

  • DNS: Each subdomain needs an A, AAAA, or environment-appropriate record pointing to the Nginx host.
  • Host matching: Nginx compares the HTTP Host header with server_name values and selects one virtual server block.
  • Filesystem mapping: The selected block’s root is the base directory. Nginx appends the URI to it when looking for a file.

If a request does not match the intended name, it can fall through to the default server. That is why a correctly written file can still produce the standard Nginx welcome page.

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.

Recommended directory and configuration layout

For a small, known set of subdomains, keep one site per directory and one server block per hostname:

/var/www/app.example.com/public
/var/www/blog.example.com/public
/etc/nginx/conf.d/app.example.com.conf
/etc/nginx/conf.d/blog.example.com.conf

Linux installations commonly keep the main configuration under /etc/nginx and include feature or site files from /etc/nginx/conf.d. Your distribution may instead use a sites-enabled-style layout; the important requirement is that the active http configuration includes both files.

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application:Upgraded attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Warranty & Support: Our Electric air duster comes with 5 years warranty and 24/7 customer service. During this period, if you have any questions,pls kindly feel free to contact us.

Build two subdomains with separate roots

1. Create a test page in each root

Create the directories and put unmistakably different content in each one. The Nginx worker must be able to traverse every parent directory and read the files.

sudo mkdir -p /var/www/app.example.com/public
sudo mkdir -p /var/www/blog.example.com/public

sudo tee /var/www/app.example.com/public/index.html >/dev/null <<'EOF'
<!doctype html>
<html><body><h1>Application subdomain</h1></body></html>
EOF

sudo tee /var/www/blog.example.com/public/index.html >/dev/null <<'EOF'
<!doctype html>
<html><body><h1>Blog subdomain</h1></body></html>
EOF

Use permissions appropriate for your operating system and Nginx worker account. A permission problem is different from a routing problem: routing selects the block, while permissions determine whether the selected worker can read the resulting path.

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

2. Create one server block per hostname

Place the following in the active configuration directory, adjusting the hostnames and paths to your environment:

server {
    listen 80;
    server_name app.example.com;
    root /var/www/app.example.com/public;
    index index.html;
}

server {
    listen 80;
    server_name blog.example.com;
    root /var/www/blog.example.com/public;
    index index.html;
}

Both blocks may listen on the same address and port. Nginx distinguishes them by server_name. With the configuration above, a request for /images/logo.png on the application hostname is looked up under /var/www/app.example.com/public/images/logo.png; the same URI on the blog hostname is looked up under the blog root.

3. Make sure the files are included

A syntactically correct file has no effect if the running http context never includes it. Check your distribution’s include directives and confirm both configuration files are part of the active configuration. If your system uses a separate enabled-sites directory, enable the files using that system’s normal mechanism.

Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
  • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
  • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
  • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
  • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth

4. Point DNS at the Nginx host

Create the records for app.example.com and blog.example.com. An A record handles IPv4 and an AAAA record handles IPv6; use the record types required by your hosting environment. DNS caching and propagation can delay the change, so a newly created record may not be visible from every network immediately.

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

DNS does not choose a document root. It only gets the connection to the Nginx host; the Host header and Nginx configuration perform the final selection.

5. Test and reload Nginx

Validate the complete configuration before reloading:

sudo nginx -t

Proceed only when the test reports a successful configuration. Then reload through your operating system’s service manager so workers receive the new configuration without unnecessarily stopping active connections:

sudo systemctl reload nginx

If your installation does not use systemctl, use its documented service-management command after the same configuration test.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black
  • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
  • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
  • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
  • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
  • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.

6. Verify each hostname

Open both hostnames and confirm that each distinctive test page appears. An HTTP client is useful because it makes the hostname explicit:

curl -i http://app.example.com/
curl -i http://blog.example.com/

Before DNS is live, send the intended Host header to the server’s IP address:

curl -i -H 'Host: app.example.com' http://SERVER_IP/
curl -i -H 'Host: blog.example.com' http://SERVER_IP/

Replace SERVER_IP with the Nginx server address. This test separates Nginx routing from DNS propagation.

How Nginx chooses a server block

When several virtual servers listen on the same address and port, Nginx examines the request’s Host header. Matching has a defined order: exact names are considered before wildcard names, and regular-expression names have their own precedence rules. A hostname that matches none of the intended names is handled by the default server for that listening socket.

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

Prefer exact names for independent sites

Use server_name app.example.com; and server_name blog.example.com; when deterministic routing matters. Exact names make configuration review and troubleshooting straightforward.

Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
  • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
  • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
  • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
  • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.

Understand wildcard capture

A wildcard can be useful when many hostnames intentionally share behavior, but it can also capture a name you expected to reach another block. Review wildcard and regular-expression entries whenever an apparently correct exact block is ignored.

Be deliberate about the default server

The default server receives unmatched requests. Leaving an unintended default block enabled is a common reason for seeing the generic welcome page. Keep a deliberate default policy and avoid relying on it for production hostnames.

Static roots versus proxied applications

The example above serves files directly from disk. That is appropriate for static HTML, CSS, JavaScript, images, and similar assets. A subdomain that runs an application server usually needs a different design: Nginx still selects the block with server_name, but the block forwards requests to an upstream service instead of resolving every URI below a static root.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Design What selects the site Where content comes from Best fit
Separate static roots Exact server_name in each block Files below that block’s root Independent static sites or asset trees
Wildcard hostname block Wildcard matching Usually shared logic or computed upstream behavior Many intentionally uniform subdomains
Reverse-proxy block Exact or wildcard server_name An application listening behind Nginx Dynamic web applications and APIs

Do not add a filesystem root merely because a proxied application has a hostname. Choose the content model first, then configure the matching block accordingly.

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

HTTP and HTTPS configurations

HTTP-only blocks are useful for initial routing tests, but production sites normally need TLS. HTTPS introduces another listening endpoint and certificate configuration. Create an HTTPS server block for each hostname (or use a deliberate certificate and hostname strategy), keep the same exact-name routing, and decide whether the port-80 block should serve content or redirect to HTTPS. Test both endpoints after certificates and redirects are in place.

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.

The key routing rule does not change: the request must match the intended server_name on the listener that received it, and the selected block must point at the intended root or upstream.

Troubleshooting by symptom

The default Nginx page appears

  • Check that the browser or client is requesting the expected hostname, not the server IP or a misspelled subdomain.
  • Compare the hostname character-for-character with server_name.
  • Confirm the file is included in the active http configuration.
  • Check which block is the default for that address and port and whether a wildcard or regular-expression name is capturing the request.
  • Run nginx -t, then reload after correcting the configuration.

A request returns 404

A 404 generally means routing reached a block but the requested URI does not exist below its configured root. For a request such as /images/logo.png, verify the file is at the corresponding path under the selected root, including capitalization and every directory component. A wrong root can therefore look like a missing-file problem even when the file exists under another site.

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

Nginx reports permission denied

Check traversal permissions on every parent directory and read permission on the target file for the Nginx worker account. Also check mandatory access-control policies where your operating system uses them. Fix permissions on the selected root rather than changing the hostname mapping.

Edits seem to be ignored

Editing a file does not change running workers until the file is included, the configuration passes validation, and Nginx is reloaded. Repeat all three checks. If the syntax test fails, Nginx keeps the previous working configuration rather than applying the broken edit.

Only one subdomain works

Test DNS records independently and then test with explicit Host headers. If the header test works but the public hostname does not, investigate DNS caching or an intermediate proxy. If the header test also fails, inspect the server-name match, include path, listening address, and default-server selection.

A wildcard sends traffic to the wrong site

Search all active files for wildcard and regular-expression server_name directives. Remove an overly broad pattern or replace it with exact names when the sites need independent roots.

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

Operational checklist

  • Each subdomain resolves to the intended Nginx host.
  • Each hostname has an exact server_name where deterministic routing is required.
  • Each static site has its own root and a test file with distinctive content.
  • The Nginx worker can traverse the root and read requested files.
  • Configuration files are included by the active http context.
  • nginx -t succeeds before every reload.
  • Both browser requests and explicit-Host tests return the expected content.
  • HTTPS blocks, certificates, and HTTP-to-HTTPS behavior are tested separately when TLS is enabled.

When to consolidate configuration

One file per subdomain is easiest to audit when the set is small and each site has different settings. A consolidated file can be reasonable when several blocks share logging, TLS, headers, or deployment conventions, provided every block still has an unambiguous hostname and root. The decision is organizational; it does not change Nginx’s matching or URI-to-root rules.

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.