Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk9 min

How to Set Up a Subdomain on a Single VPS

A practical guide to hosting multiple subdomains on one VPS: configure A, AAAA or CNAME records, route each hostname with Nginx, secure it with ACME HTTPS, and diagnose common failures.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You can host app.example.com, api.example.com and other subdomains on one VPS and one public IP. The setup has separate layers: DNS points each hostname to the VPS, Nginx selects the matching hostname and serves or proxies the request, and an ACME client installs a certificate for HTTPS. Configure those layers in that order, keep application ports private, and verify IPv6 before publishing an AAAA record.

The architecture: three separate jobs

A subdomain does not become available merely because a DNS record exists. A complete deployment needs all of the following:

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.
  • DNS resolution: the authoritative DNS provider returns the VPS address for the hostname.
  • Network access: the VPS and any upstream provider firewall allow TCP 80 for HTTP and TCP 443 for HTTPS.
  • Web-server routing: Nginx matches the requested hostname with server_name and either serves files or forwards the request to an application.

For example, app.example.com can proxy to 127.0.0.1:3000 while api.example.com proxies to 127.0.0.1:8080. Both names can use the same public IPv4 address. Nginx distinguishes them by the hostname sent in the request, and TLS Server Name Indication (SNI) lets several HTTPS names share one IP address.

Plan the hostname and its application target

Choose each hostname and decide what should answer it before changing DNS. Record the local listener for every application; the examples below use reserved documentation address 203.0.113.10, so replace it with your VPS’s real public address.

#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.
Hostname Purpose Nginx target
app.example.com Web application 127.0.0.1:3000
api.example.com API service 127.0.0.1:8080
blog.example.com Static files /var/www/blog

Using loopback addresses keeps the application ports off the public Internet. Nginx is the public entry point; clients connect to 80 or 443, and Nginx connects locally to the selected upstream.

Create the DNS record

Sign in to the provider that is authoritative for example.com and add a record whose name is normally just the label, such as app or api. Cloudflare’s subdomain documentation, updated April 16, 2026, states: “To host content on a subdomain of your domain, first ensure that your hosting provider can serve content for the given hostname (<subdomain>.example.com).”

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.
Record Name Value in this example Use it when
A app 203.0.113.10 The VPS accepts IPv4 traffic.
AAAA app Your VPS’s configured IPv6 address IPv6 reaches the same Nginx service and firewall path.
CNAME app Another hostname, such as a provider endpoint The alias should follow a hostname rather than point directly to an address.

Use an A record for the VPS’s IPv4 address. Add an AAAA record only after testing that IPv6 traffic reaches this VPS, its firewall, and Nginx; an unreachable AAAA path can make browsers or certificate validation choose a broken route. A CNAME is for an alias to another hostname, not for entering an IPv4 address.

After saving the record, query the authoritative result from a shell:

dig +short app.example.com

The expected IPv4 result is the VPS address. Query IPv6 separately if you published AAAA:

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.
dig +short AAAA app.example.com

If the answer is wrong, check which nameservers are authoritative, whether the record name was entered as app rather than an unintended full name, and whether conflicting A or AAAA records remain.

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

Open only the public network path

Allow inbound TCP 80 and 443 in both layers that can filter traffic: the VPS’s local firewall and the hosting provider’s network firewall. Port 80 is needed for ordinary HTTP and for the HTTP-01 ACME challenge; port 443 carries HTTPS. Do not expose ports 3000 or 8080 when Nginx is the public reverse proxy. Bind those applications to loopback where possible and allow only local connections.

Before requesting a certificate, make sure a request to the hostname can reach Nginx on port 80. If a provider proxy or CDN sits in front of the VPS, its mode and origin firewall rules must still permit the ACME challenge to reach the correct web server.

Configure an Nginx server block

Static subdomain

Create a separate server block for a site that consists of files. A typical file is /etc/nginx/sites-available/blog.example.com:

server {
    listen 80;
    listen [::]:80;
    server_name blog.example.com;

    root /var/www/blog;
    index index.html;

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

Create the document root and place an index.html there. Enable the site using the distribution’s normal sites-enabled mechanism, for example:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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 ln -s /etc/nginx/sites-available/blog.example.com /etc/nginx/sites-enabled/blog.example.com

Ensure the Nginx worker can read the files and that the path does not contain a permissions barrier. The try_files rule serves an existing file or directory and returns 404 instead of passing an unknown path elsewhere.

Application subdomain

For an application listening on 127.0.0.1:3000, use a reverse-proxy block:

server {
    listen 80;
    listen [::]:80;
    server_name app.example.com;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

The server_name value must exactly match the hostname users request. Nginx uses hostname matching to choose among server blocks listening on the same address and port. The proxy_pass directive forwards the request to the local application; the forwarded headers preserve the original host, client address and scheme for applications that use them.

For api.example.com, create another block with its own server_name and change only the upstream:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
server {
    listen 80;
    listen [::]:80;
    server_name api.example.com;

    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Keep each hostname in its own block while you are setting up the system. That makes the target, logs and later HTTPS changes easy to audit and roll back.

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.

Validate the configuration before reloading

Never reload an untested configuration. Run:

sudo nginx -t

A successful test reports that the syntax is valid and the test is successful. Only then reload:

sudo systemctl reload nginx

If the test identifies a file, directive or permission error, fix that error and run nginx -t again. A reload applies the new configuration without unnecessarily stopping existing workers.

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

With DNS and port 80 working, test the hostname directly:

curl -I http://app.example.com

For a proxy site, the response should come from the application. For a static site, it should be the Nginx-served file. If DNS is not yet returning the VPS address but you need to test the web server, use a temporary hosts-file entry on your workstation or query the VPS by address with an explicit host header; remove that temporary override after DNS is correct.

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

Issue and install HTTPS

Use an ACME client, such as Certbot, for a trusted certificate. The HTTP-01 challenge requires the certificate authority to connect directly to the hostname on port 80, so confirm DNS, firewall rules and the port-80 server block first. If IPv6 is published, the validation service must also be able to reach the same Nginx service over IPv6.

  1. Verify that dig +short app.example.com returns the VPS IPv4 address and that any AAAA result is reachable.
  2. Confirm that TCP 80 is open in both firewalls and that Nginx answers the hostname.
  3. Run your ACME client for the exact hostname, for example app.example.com. Follow the client package’s installation instructions for your operating system.
  4. Install the issued certificate and private key in a 443 server block, or allow the client to edit the Nginx configuration when that integration is supported.
  5. Configure the HTTP server block to redirect to HTTPS and reload Nginx after another nginx -t check.
  6. Enable and verify the client’s renewal timer or scheduled job. A certificate that works today still needs an automatic renewal path.

A resulting HTTPS block for an application has this shape; the exact certificate paths depend on the ACME client:

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.
server {
    listen 443 ssl;
    listen [::]:443 ssl;
    server_name app.example.com;

    ssl_certificate     /path/to/fullchain.pem;
    ssl_certificate_key /path/to/privkey.pem;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

server {
    listen 80;
    listen [::]:80;
    server_name app.example.com;
    return 301 https://$host$request_uri;
}

Replace the certificate paths with the paths created by your client. The HTTP block remains available so that clients and the ACME HTTP-01 challenge can connect; normal requests receive a permanent redirect to HTTPS.

Verify the finished subdomain

Check each layer independently instead of treating a browser error as a single problem.

  1. DNS: run dig +short app.example.com and, when applicable, dig +short AAAA app.example.com. Confirm every returned address belongs to the intended service.
  2. HTTP: run curl -I http://app.example.com and verify the redirect target is the same hostname over HTTPS.
  3. HTTPS: open https://app.example.com, inspect the certificate hostname and expiration, and confirm the page or API response is from the intended upstream.
  4. Routing: review Nginx access and error logs while making a request. The access log shows which hostname and status were served; the error log often identifies a failed upstream connection or permission problem.
  5. Application: test a health endpoint or normal request and verify that the application sees the forwarded host and scheme it expects.

During certificate troubleshooting, requesting a path under /.well-known/ can help establish whether the challenge request reaches the correct server block. Do not permanently expose debugging content.

Add more subdomains on the same VPS

Repeat the process for each name:

  1. Add an A record for the new label, and an AAAA record only when IPv6 is ready.
  2. Choose a distinct local upstream port or a separate document root.
  3. Create an Nginx server block with the new server_name.
  4. Run sudo nginx -t, reload Nginx, and test HTTP.
  5. Obtain a certificate containing that exact hostname, then configure the 443 block and redirect.

Several HTTPS names can share one IPv4 address because the browser sends the requested hostname during the TLS handshake through SNI. NGINX describes SNI as “a more generic solution for running several HTTPS servers on a single IP address,” allowing the browser to pass the requested server name during the SSL handshake. The certificate still must contain each hostname; sharing an IP does not make a certificate valid for unrelated names.

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

Troubleshoot by symptom

Symptom Likely cause Checks and fix
DNS returns the wrong address Incorrect record, wrong authoritative nameservers, or stale/conflicting A or AAAA records Check the authoritative zone, record label and every address returned by dig. Remove conflicting records and correct the target.
ACME certificate challenge fails Port 80 blocked, proxy/CDN mode prevents direct validation, or an unreachable IPv6 path Permit TCP 80, make the hostname reach the intended Nginx block, review proxy settings, and remove or repair AAAA until IPv6 reaches the service.
502 Bad Gateway The application is stopped or is not listening at the address and port in proxy_pass Check the application’s service status and listening socket, confirm 127.0.0.1:3000 or :8080 is correct, then inspect the Nginx error log.
The default site appears Another server block is selected first or the requested hostname is absent from server_name Check the exact hostname in the request and configuration, disable or adjust the default block if appropriate, test with nginx -t, and reload.
Browser reports an HTTPS warning The certificate lacks the exact hostname, has expired, or the browser reached a different IP Inspect the served certificate, renew it if necessary, compare DNS A/AAAA results with the VPS, and verify the 443 block for that hostname.

Operational safeguards

  • Keep a copy of each working Nginx configuration before editing so a failed change can be rolled back quickly.
  • Use one clear server block per hostname and one documented upstream per application.
  • Retest with nginx -t before every reload.
  • Monitor both Nginx logs and the application logs; a successful TCP connection does not prove that the upstream is healthy.
  • Renew certificates automatically and test renewal before the expiration date.
  • Do not publish an AAAA record as a placeholder. It must lead to a functioning IPv6 route, firewall rule and Nginx listener.
  • Leave application ports private unless a separate design specifically requires public access.

Final setup checklist

  • The chosen subdomain resolves to the VPS’s intended IPv4 address.
  • Any published IPv6 address reaches the same Nginx service.
  • Inbound TCP 80 and 443 are allowed at both firewall layers.
  • The Nginx block contains the exact server_name and correct static root or proxy_pass target.
  • sudo nginx -t succeeds before reload.
  • The ACME certificate includes the exact hostname and has an enabled renewal mechanism.
  • HTTP redirects to HTTPS, and HTTPS serves the intended site or application rather than the default block.

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.