October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix 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 desk8 min

Do You Need a DNS Record for Each Virtual Host Domain?

Every public virtual-host hostname needs DNS resolution, but it does not need a unique IP. This guide explains shared-IP hosting, Apache and Nginx matching, HTTPS SNI, wildcard DNS, and troubleshooting.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Usually, yes. Every public hostname that people are expected to visit—such as example.com, www.example.com, or shop.example.com—needs a DNS resolution path. That does not mean every hostname needs a different IP address, server, or application. In name-based virtual hosting, several hostnames can resolve to one address, and Apache or Nginx selects the site by reading the hostname sent with the request.

What DNS and virtual hosting each do

DNS answers the first question in a web request: “Where should this hostname connect?” A virtual-host configuration answers the next question: “Which site should this server return after the connection arrives?” They are separate systems.

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.

Suppose three public names are intended to reach one server:

  • example.com
  • www.example.com
  • shop.example.com

Each is a distinct DNS name. Each needs an A record, an AAAA record, a CNAME or another alias mechanism supported by the DNS provider, or a wildcard that produces a resolution path. The records can all point to the same IP address or load-balancer endpoint. On the server, the names must also appear in the relevant virtual-host definition, either as individual names or through an intentional wildcard or alias.

#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.

Adding ServerName, ServerAlias, or Nginx’s server_name directive does not publish a DNS record. Apache’s documentation puts the boundary plainly: creating virtual-host configurations “does not magically cause DNS entries to be created for those host names.” If a name does not resolve to the serving endpoint, users cannot reach that virtual host regardless of how correct the web-server file is.

How a request reaches the correct virtual host

1. DNS lookup happens first

The browser, operating system, or other client looks up the hostname in the URL. An A record supplies an IPv4 address; an AAAA record supplies an IPv6 address. A CNAME or provider-specific alias can point the name at another hostname or service endpoint. Several names may resolve to one address.

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

If the lookup returns no usable answer, the request stops before Apache or Nginx is contacted. A server-side virtual-host file cannot compensate for a missing, incorrect, or delegated-to-the-wrong DNS record.

2. The client connects and identifies the hostname

After connecting to the returned address, an HTTP client sends the hostname in the Host: header. Apache compares that value with ServerName and ServerAlias. Nginx compares it with the names listed in server_name. This is why many sites can share one IP: the address gets the connection to the machine, and the hostname chooses the site.

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.

3. HTTPS can select a context before HTTP

With HTTPS, TLS negotiation occurs before the encrypted HTTP request is available. Modern clients send the requested hostname through Server Name Indication (SNI), allowing the server to choose the appropriate certificate and virtual-server context. The certificate presented must cover every hostname visitors use. A DNS record alone does not make a certificate valid, and a certificate alone does not make a hostname resolve.

4. An unmatched name falls through to a default

If no configured name matches, Apache or Nginx uses its default or first matching virtual host according to the server’s matching rules. An unknown hostname can therefore display the wrong customer’s site, a generic landing page, or an unintended application. A deliberate default site and explicit handling for unknown names prevent accidental content disclosure.

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

Does every hostname need its own A record?

No. The requirement is a DNS resolution path for each public hostname, not a unique A record or unique address.

Public name Possible DNS approach Server-side requirement
example.com A and/or AAAA record to the serving address List as Apache ServerName or Nginx server_name
www.example.com A/AAAA record, or a CNAME/alias supported by the DNS provider List as Apache ServerAlias or another Nginx name
shop.example.com A/AAAA record, CNAME/alias, or a matching wildcard Configure a separate virtual host or include the name in an existing block
Any future subdomain under a wildcard Wildcard DNS, subject to provider behavior Use a matching wildcard or explicit server name and ensure the application handles it

For example, www.example.com could be an alias to example.com, while both ultimately reach the same endpoint. The DNS design does not decide which document root or application responds; the web-server configuration does.

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

Name-based hosting versus IP-based hosting

Most modern deployments use name-based virtual hosting because it conserves addresses. IP-based hosting remains useful when sites must be separated at the address level or when a design specifically requires a distinct address for each host.

Characteristic Name-based virtual hosting IP-based virtual hosting
IP addresses Multiple hostnames can share one IP or endpoint. Each host uses a separate IP address; Apache describes this as requiring a separate address for each host.
DNS management Every public name still needs DNS, but records can target the same address. Every name points to its designated address.
Site selection Uses the HTTP hostname and, for HTTPS, TLS SNI. Uses the destination IP of the connection.
TLS certificates SNI lets one address serve different certificate contexts; each requested name must be covered. Address separation can simplify isolation, but certificates are still required for the names used.
Isolation Configuration mistakes can expose a default site or route an unknown name incorrectly. Address-level separation provides stronger boundaries between hosts.
Unknown host behavior Usually reaches the configured default or first matching virtual host. Reaches the virtual host bound to the destination address.

Configuring Apache correctly

Apache requires a ServerName in each name-based virtual-host block. Additional hostnames go in ServerAlias. The DNS records must already direct those names to the address where Apache listens.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Create DNS resolution. Add an A and/or AAAA record, or an alias supported by your DNS provider, for every hostname users will enter. Confirm that the result is the server or load-balancer endpoint serving Apache.
  2. Define the primary name. Set ServerName to the canonical hostname for the site.
  3. Add alternate names. Put names such as www.example.com in ServerAlias. If an alias should redirect rather than serve identical content, implement that redirect deliberately in the site configuration or application.
  4. Bind the virtual host. A typical HTTP block has the following shape:
<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com shop.example.com
    DocumentRoot /var/www/example
</VirtualHost>
  1. Configure HTTPS separately. The TLS virtual host must include the same intended names and a certificate covering them. SNI allows Apache to choose the right TLS context when several sites share an address.
  2. Set a safe default. Decide what an unmatched hostname should receive. A neutral response or rejection is safer than allowing the first customer site to become the accidental default.

When several Apache virtual hosts share the same address and port, Apache compares the request hostname. If none matches, the first listed matching virtual host is used, so file ordering and an explicit default matter.

Configuring Nginx correctly

Nginx places host matching in the server_name directive. One server block can list several exact names, wildcard names, or regular-expression names. Nginx evaluates them in a defined order; during HTTPS, the SNI name can be available before the HTTP Host header.

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.
  1. Publish DNS names. Create a resolution path for each hostname, pointing to the Nginx address or the front-end service that forwards to it.
  2. List exact names when the set is known. An explicit list avoids unintentionally accepting unrelated subdomains.
  3. Use a wildcard only intentionally. A wildcard can cover a family of names, but the application and certificate still need to support the hostnames that clients use.
  4. Define a default server. Mark one listener as the deliberate default and decide how it handles unknown hosts.
server {
    listen 80;
    server_name example.com www.example.com shop.example.com;
    root /srv/www/example;
}

For HTTPS, configure the TLS server block and certificate to cover the names in use. A wildcard in Nginx does not create DNS records; it only changes how Nginx matches a name after the connection reaches it.

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

Using aliases and wildcard DNS

Aliases reduce repetitive records but do not remove the underlying requirement that a visitor’s hostname resolve. A DNS provider may support CNAME-style aliases, flattened aliases for an apex name, or other mechanisms. The exact behavior depends on that provider, so verify that the chosen record type is allowed at the name you are publishing.

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.

A wildcard DNS record can provide answers for multiple otherwise-unlisted subdomains. It does not normally replace an explicit record that already exists, and it does not automatically configure Apache, Nginx, the application, or TLS. Pair a wildcard with an intentional wildcard or catch-all server rule, and decide what should happen for names that were never meant to be public.

Certificate coverage is a separate check. Every hostname in a browser’s address bar must be covered by the certificate selected during TLS. If DNS resolves a new subdomain but the certificate or virtual-host matching does not include it, users can receive a certificate warning or the wrong site.

Why the wrong site appears when domains share an IP

Wrong-site behavior is usually a matching or DNS problem, not proof that shared-IP hosting is impossible.

Symptom Likely cause What to check
The hostname does not connect No record, incorrect record, or DNS delegation pointing elsewhere Query the name and confirm its A/AAAA or alias result matches the intended endpoint.
The default site appears The request hostname is missing from Apache’s ServerName/ServerAlias or Nginx’s server_name Compare the exact spelling in DNS, the URL, and the virtual-host configuration.
HTTPS shows the wrong certificate SNI selected another TLS context, or the certificate does not cover the requested name Check the HTTPS virtual-host names and certificate name coverage.
One name works while its alias fails The alias resolves differently or was not included in the server block Test each hostname independently in DNS and in the web-server configuration.
An unknown subdomain exposes a real site No safe default or catch-all behavior Create an explicit default server and reject or neutralize unrecognized hostnames.

For basic verification, query each public name independently with a DNS tool such as dig, then send an HTTP request using that exact hostname. Testing both HTTP and HTTPS is important because TLS selection occurs before ordinary HTTP host matching.

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.

A practical design checklist

  • List every hostname that users, bookmarks, APIs, redirects, or certificates will use.
  • Give each name a DNS resolution path: A, AAAA, an allowed alias, or an intentional wildcard.
  • Confirm that all records lead to the correct server, proxy, or load-balancer endpoint.
  • Include every exact hostname in Apache’s ServerName/ServerAlias or Nginx’s server_name.
  • For HTTPS, make sure SNI-based selection and certificate coverage include each name.
  • Choose a deliberate default virtual host for unmatched names.
  • Test each hostname separately, including alternate names and newly created subdomains.

When separate IP addresses are justified

Use separate addresses when address-level isolation is a requirement, when policy or infrastructure demands a distinct binding, or when separating traffic at the network layer is more important than conserving addresses. Apache defines IP-based virtual hosting around the connection’s destination IP, so each host needs its own address in that model.

Do not allocate separate IPs merely because several domains share one server. If the sites can safely use name-based matching, one address can serve many names. The critical work is keeping DNS, hostname matching, TLS certificates, and the default-site policy consistent.

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.