Point a Namecheap Subdomain to a Separate Server: DNS and Nginx Setup

by Fahim Mahmud Chisti

To point a Namecheap subdomain such as app.example.com to a separate server, you add one A record in Namecheap’s Advanced DNS and give that server an Nginx server block for the subdomain. Your main site and email keep working because no other record changes. At the end, the subdomain serves your app from the second server over HTTPS.

Quick answer: In Namecheap, open Domain List, click Manage, go to Advanced DNS and add an A record with Host app and your second server’s IP. Then create an Nginx server block for app.example.com on that server and add a free certificate with Certbot.

  1. Add the A record (Host app, Value = server IP) and leave the @, www and MX records alone.
  2. Check it with dig +short app.example.com @8.8.8.8.
  3. On the second server, create a server block with server_name app.example.com; and enable it.
  4. Run sudo nginx -t, then reload Nginx.
  5. Run sudo certbot --nginx -d app.example.com to switch on HTTPS.
In this guide
  1. Before You Start
  2. The Two-Server Architecture
  3. Step 1: Add the Subdomain Record in Namecheap BasicDNS
  4. Step 2: Verify DNS Propagation from the Command Line
  5. Step 3: Create the Nginx Server Block on the Target Server
  6. Step 4: Enable the Virtual Host and Test Syntax
  7. Step 5: Issue a Free Let’s Encrypt SSL Certificate
  8. Common Problems: Firewall Rules and the Default Server Trap
  9. Testing Your New Subdomain
  10. If It Still Doesn’t Work
  11. Frequently Asked Questions
  12. Next Steps
Close up of server rack networking hardware representing separate subdomain routing

Before You Start

  • Namecheap access: your Namecheap login, and the domain’s nameservers set to Namecheap BasicDNS. If the nameservers point somewhere else (Cloudflare or your host, for example), add the same A record at that DNS provider instead; records added in Namecheap would be ignored.
  • Server access: SSH with sudo on the second server (Ubuntu 22.04 or 24.04 with Nginx installed) and its public IPv4 address.
  • Time: about 20–30 minutes, plus a few minutes for DNS.
  • Safety: adding a new host record does not change existing ones. Do not edit or delete the @, www, MX or TXT records, or you can take down the main site or email.

The Two-Server Architecture

When you split services across machines, you don’t touch your primary nameservers. Your root domain (example.com) stays on your static host or managed provider, while your subdomain points straight to a dedicated IP on an unmanaged VPS or cloud instance.

Here is how the setup breaks down:

  • Main Site: example.com points to Server A (e.g., 198.51.100.10) hosting your WordPress or landing page.
  • App Subdomain: app.example.com points to Server B (e.g., 203.0.113.45) running a Node.js, Go, or Python backend behind an Nginx reverse proxy.
  • DNS Authority: Namecheap BasicDNS handles resolution for both records independently.

If you need several subdomains on different servers or platforms, our guide to routing subdomains to different servers in Namecheap DNS covers which record type to use for each case.

Step 1: Add the Subdomain Record in Namecheap BasicDNS

Log in to Namecheap and head to your Domain List. Hit Manage next to your domain, then open the Advanced DNS tab.

Check the Host Records table. Leave your root records (@) and www entries alone so you do not take down your main site.

Click Add New Record and fill in:

  • Type: A Record
  • Host: Just the subdomain prefix (e.g., app for app.example.com, or api for api.example.com). Do not enter the full domain here; typing app.example.com creates app.example.com.example.com.
  • Value: The public IPv4 address of your target server (e.g., 203.0.113.45).
  • TTL: Set to Automatic or 1 min so changes take effect quickly while testing.

Hit the green checkmark to save. If your secondary server also has an IPv6 address, add a matching AAAA Record using the same host prefix and your server’s IPv6 value.

Step 2: Verify DNS Propagation from the Command Line

Namecheap’s nameservers usually pick up a new record within a few minutes, but your own computer or ISP may still have an old answer cached. Ask a public resolver such as Google DNS (8.8.8.8) or Cloudflare DNS (1.1.1.1) directly.

Run this from your own computer’s terminal:

dig +short app.example.com @8.8.8.8

If the DNS record propagated, you will see your target server IP immediately:

203.0.113.45

If you get an empty response or an NXDOMAIN error, query Namecheap’s nameservers directly to make sure the record actually saved in their zone file:

dig +short app.example.com @dns1.registrar-servers.com

Once Namecheap returns the IP, you know the record is live. Any remaining delay is just local resolver TTL caching.

Step 3: Create the Nginx Server Block on the Target Server

SSH into your secondary server (Server B). Nginx needs a server block (its name for a virtual host) that matches this subdomain; otherwise requests fall through to the default site.

Create a new configuration file in /etc/nginx/sites-available/:

sudo nano /etc/nginx/sites-available/app.example.com.conf

Paste in the configuration below. It serves static files by default; to send traffic to an app running on port 3000 instead, follow the comment inside the location block:

server {
    listen 80;
    listen [::]:80;
    server_name app.example.com;
    # Path for static files or ACME challenges
    root /var/www/app.example.com/public;
    index index.html index.htm;
    # Security headers
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Content-Type-Options "nosniff" always;
    # Logging
    access_log /var/log/nginx/app.example.com.access.log;
    error_log /var/log/nginx/app.example.com.error.log warn;
    location / {
        # If serving static files:
        try_files $uri $uri/ =404;
        # Or if proxying to a local backend app (delete the try_files line and uncomment below):
        # proxy_pass http://127.0.0.1:3000;
        # proxy_http_version 1.1;
        # proxy_set_header Upgrade $http_upgrade;
        # proxy_set_header Connection 'upgrade';
        # 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;
        # proxy_cache_bypass $http_upgrade;
    }
}

Step 4: Enable the Virtual Host and Test Syntax

Create the webroot directory if you are serving static files, set user permissions, and symlink the file into /etc/nginx/sites-enabled/.

Run these on the target server:

sudo mkdir -p /var/www/app.example.com/public
sudo chown -R www-data:www-data /var/www/app.example.com
sudo chmod -R 755 /var/www/app.example.com
# Create a test index file
echo "<h1>app.example.com is live</h1>" | sudo tee /var/www/app.example.com/public/index.html
# Enable the configuration
sudo ln -s /etc/nginx/sites-available/app.example.com.conf /etc/nginx/sites-enabled/

Always test your Nginx configuration syntax before reloading the daemon:

sudo nginx -t

You should see a successful test confirmation:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

If you see an error instead, fix the line it names before reloading; the server keeps running the old configuration until then. Once the test passes, reload Nginx to apply the new site:

sudo systemctl reload nginx

Now check it from your own computer with curl -I http://app.example.com. You should get 200 OK, and opening the address in a browser shows the “app.example.com is live” test page. If you see a different site or the “Welcome to nginx” page, jump to the default server fix below.

Step 5: Issue a Free Let’s Encrypt SSL Certificate

Don’t leave the subdomain on plain HTTP. Certbot gets a free certificate from Let’s Encrypt and sets up HTTPS for you. It needs DNS to point at this server and port 80 to be reachable, which Steps 2 and 4 confirmed.

On Server B, install Certbot from snap if you haven’t already:

sudo snap install core; sudo snap refresh core
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/local/bin/certbot

Request the certificate for your subdomain:

sudo certbot --nginx -d app.example.com

Certbot reads your server block, proves you control the subdomain through the HTTP-01 challenge (a temporary file Let’s Encrypt fetches over port 80), and updates /etc/nginx/sites-available/app.example.com.conf to serve HTTPS on port 443 and redirect HTTP to HTTPS. When it finishes, it confirms the certificate was deployed and that automatic renewal is scheduled.

If you prefer a single wildcard certificate across multiple subdomains, check out our guide on setting up Let’s Encrypt wildcard certificates with Certbot DNS-01.

Common Problems: Firewall Rules and the Default Server Trap

Two issues commonly get in the way at this point.

1. Unopened Ports on the Target Host Firewall

Ubuntu ships with ufw installed but inactive, and many VPS images and hardening guides switch it on. If it is active (check with sudo ufw status), external traffic drops silently even though Nginx is listening on ports 80 and 443.

Run this on Server B to open web traffic:

sudo ufw allow 'Nginx Full'
sudo ufw reload

If ufw is still inactive, allow SSH first (sudo ufw allow OpenSSH) before you ever run sudo ufw enable, or you will lock yourself out.

If you run on AWS EC2, GCP, or DigitalOcean with external cloud firewalls, ensure your inbound security rules permit port 80 and 443 from 0.0.0.0/0.

2. The Default Server Catch-All Conflict

If you leave the default Nginx site enabled at /etc/nginx/sites-enabled/default with listen 80 default_server;, requests with mismatched host headers or missing SNI can land on the default page instead of your new block.

If no other site on Server B relies on the default site, remove its symlink. The commands below test the configuration before reloading, so a mistake will not take Nginx down:

sudo rm /etc/nginx/sites-enabled/default
sudo nginx -t
sudo systemctl reload nginx

Testing Your New Subdomain

Test the live HTTPS connection from your local machine using curl -I to inspect response headers and the TLS handshake:

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

You should see a 200 OK (or a 301 if your app redirects) coming straight from your secondary server. The example below is from the static test page; your date, Nginx version and sizes will differ:

HTTP/1.1 200 OK
Server: nginx/1.24.0 (Ubuntu)
Date: Thu, 20 Feb 2025 14:18:22 GMT
Content-Type: text/html
Content-Length: 33
Last-Modified: Thu, 20 Feb 2025 14:15:00 GMT
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff

Your apex domain keeps running on your main server, while the subdomain is served by the second one.

If It Still Doesn’t Work

  • dig returns nothing, even from dns1.registrar-servers.com: the record was not saved, or the domain does not use Namecheap BasicDNS. Check the nameservers on the domain’s page and add the record where DNS is really hosted.
  • dig still shows an old IP: a resolver cached the previous answer. Wait for the TTL to pass, and test against @dns1.registrar-servers.com to see the current value.
  • The browser shows another site or “Welcome to nginx”: the new server block is not enabled, server_name has a typo, or the default site is catching the request. Check the symlink in sites-enabled and the default server section above.
  • The connection times out: a firewall on Server B or at your cloud provider is blocking ports 80 and 443.
  • Certbot fails the HTTP-01 challenge: DNS does not point at Server B yet, port 80 is blocked, or a rule in the server block intercepts /.well-known/acme-challenge/. Fix those, then run Certbot again.

Frequently Asked Questions

Does pointing a subdomain to another server affect my main website?

No. DNS routes records independently. Your apex domain (example.com) and www records keep their own A or CNAME targets. Adding or editing a subdomain host record will not touch traffic going to your main web server.

Will changing subdomain DNS break my custom domain email?

No. Mail routing is handled entirely by MX records on your apex domain or dedicated mail hosts. As long as you leave your MX and SPF/DKIM TXT records alone in Namecheap, email delivery won’t skip a beat.

Should I use an A Record or a CNAME for my subdomain?

Use an A Record if your secondary server has a static public IPv4 address. Use a CNAME Record if your target platform provides a hostname instead of a dedicated IP (like Heroku, AWS Elastic Beanstalk, or Vercel). If you are deploying to Vercel, read our guide on pointing Namecheap domains to Vercel with apex DNS.

How long does a new subdomain record take to work in Namecheap?

Usually a few minutes. Namecheap’s own nameservers serve a new record quickly, which you can confirm with dig +short app.example.com @dns1.registrar-servers.com. Resolvers that already cached an answer for that name keep it until its TTL runs out, so a lookup that failed earlier can take a little longer to clear.

Next Steps

With https://app.example.com answering from Server B, put your real app behind it. In the server block, replace the try_files line with the commented proxy lines, start the app on port 3000, and run sudo nginx -t before reloading. For a full walkthrough of running a Node app behind Nginx, see how to deploy Node.js on a Hostinger VPS with Nginx and Namecheap DNS.

all_in_one_marketing_tool