How to Point Domain to Your VPS and Set Up Free HTTPS

How to Point Domain to Your VPS and Set Up Free HTTPS

When you buy a new domain, it points nowhere until you tell it where your server lives. This guide shows you how to point domain to your vps step by step: create an A record, wait for DNS to spread, add an nginx server block, and finish with a free HTTPS certificate from Let’s Encrypt. The whole job takes about 20 to 30 minutes once you have the domain and the server IP address in front of you.

What You Need Before You Start

You need three things: a registered domain, a VPS with a public IPv4 address, and a website already running on that VPS or ready to serve. You also need access to the place where your domain’s DNS is managed. That is usually your domain registrar, but it can be a separate DNS provider such as Cloudflare if you changed your domain nameservers there. Log in to the DNS panel before you start, and find your server’s public IP address. On Ubuntu, run curl -4 ifconfig.me on the VPS to see it.

One decision to make early is whether you want the plain domain, the www version, or both. Most sites serve both, so this guide covers example.com and www.example.com.

How to Point Domain to Your VPS in Five Steps

The full process has five steps: add an A record, wait for DNS propagation, create an nginx server block, install a certificate with Certbot, and test the renewal. The first two steps happen in your DNS panel, the rest on your VPS. Do them in order, because Certbot cannot issue a certificate for a domain that does not yet resolve to your server.

Step 1: Add an A record. In your DNS panel, create a record with type A, host @ (the bare domain), and value set to your VPS IPv4 address. This is the core of any dns a record setup: the A record maps your domain name to your server’s IP. Add a second A record with host www and the same IP, so the www version works too.

Step 2: Wait for DNS propagation. DNS changes do not take effect everywhere at once. Other servers and resolvers cache the old answer until their cache expires, so the new record can take a few minutes or a few hours to show up around the world. In most cases you will see it within 15 to 30 minutes, but allow up to 24 hours before you assume something is wrong. Do not move on to Certbot until the check in the next section passes.

Check That DNS Has Propagated

Before you touch nginx, confirm the domain actually resolves to your VPS. From your own computer or from the VPS, run:

dig +short example.com
dig +short www.example.com

Both commands should print your VPS IPv4 address. If they print nothing or an old address, the record has not spread yet, or you typed the wrong IP in the DNS panel. You can also check from another network, for example your phone on mobile data, or with an online DNS checker. If dig is not installed, install it with sudo apt install dnsutils on Ubuntu or Debian.

A common mistake at this stage is editing DNS at the wrong place. If you changed your domain nameservers to Cloudflare or another provider, the A record must be added there, not at the registrar. Check which nameservers your domain uses with dig NS example.com and edit DNS at that provider.

Create an Nginx Server Block for the Domain

Once DNS resolves, tell nginx to serve your site for the new domain. Create a server block file for it:

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

Add a basic server block. This example serves files from /var/www/example.com/html:

server {
    listen 80;
    server_name example.com www.example.com;
    root /var/www/example.com/html;
    index index.html index.htm;

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

Change the root path to match where your site files actually live. If you already run another site on this VPS, the setup is the same as serving a second site, and our guide on how to add a second domain to your VPS with nginx server blocks walks through the shared details. Enable the new site and test the config:

sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

If nginx -t reports an error, fix it before you reload. Now visit http://example.com in a browser. You should see your site over plain HTTP. If you see the nginx welcome page instead, the root path in your server block points at the wrong folder. If you run several sites on one server, read our guide on how to serve multiple domains from one nginx server to keep the server blocks tidy.

Install a Free SSL Certificate with Certbot

With the site working over HTTP, you can get a free ssl certificate from Let’s Encrypt using Certbot. Certbot is the standard tool for this, and the certbot nginx https flow is simple: it proves you control the domain, fetches a certificate, and edits your nginx config to use it. Install Certbot and its nginx plugin:

sudo apt update
sudo apt install certbot python3-certbot-nginx

Then run Certbot for your domain. Include both the bare domain and www so one certificate covers both:

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

Certbot will ask for an email address for renewal notices, then ask whether to redirect HTTP traffic to HTTPS. Choose the redirect option. It will edit your nginx server block, add the certificate paths, and reload nginx for you. When it finishes, visit https://example.com. The browser should show a padlock and no warning. If you want more background on the tool itself, our guide to installing a free Let’s Encrypt SSL certificate on nginx with Certbot covers the same install in more detail.

Let’s Encrypt certificates last 90 days, so renewal is part of the setup, not an afterthought. Certbot installs a timer that tries to renew certificates twice a day. Test that the renewal works before you forget about it:

sudo certbot renew --dry-run

If the dry run succeeds, renewal is set up correctly. If it fails, check that port 80 is open and that the domain still resolves to this server. For a certificate covering many subdomains, our guide on how to set up Let’s Encrypt wildcard certificates with DNS validation explains the wildcard route instead.

Redirect HTTP to HTTPS and Test Auto-Renewal

Choosing the redirect option during the Certbot run already sends HTTP visitors to HTTPS, but confirm it works. Visit http://example.com and check that the browser ends up at https://example.com. You can also check from the command line:

curl -I http://example.com

Look for a 301 status and a Location: https://example.com/ header. If the redirect is missing, Certbot may have skipped it, and you can add it by hand. There are a few ways to write the redirect, and our guide to redirect HTTP to HTTPS in nginx compares three methods so you can pick the one that fits your config.

Finally, check the renewal timer itself so the certificate does not quietly expire in 90 days:

sudo systemctl status certbot.timer

You should see the timer listed as active. Certbot will renew the certificate on its own when fewer than 30 days remain, and it reloads nginx after a successful renewal. Mark your calendar to check the site once after the first renewal date, just to confirm the timer did its job.

Common Problems and How to Fix Them

Most failures at this point come from a small list of causes. If Certbot says it cannot reach your domain, DNS has not spread yet, or a firewall blocks port 80. Run the dig check again and confirm port 80 is open with sudo ufw status if you use UFW. Certbot needs plain HTTP on port 80 to prove you control the domain, even though the finished site uses HTTPS.

If the browser shows a certificate warning for the wrong domain, Certbot issued the certificate for a different name than the one you visited. Run sudo certbot certificates to list the names on each certificate, and re-run Certbot with the exact -d names you need. If the site loads but shows the wrong content, your nginx server block points at the wrong root folder, or another server block is catching the request first. Check server_name and the root path, then run sudo nginx -t and reload.

Once the padlock shows and the redirect works, you know how to point domain to your vps and serve it over HTTPS. The only ongoing job is the renewal timer, which runs on its own. If you later move the site to a new server, repeat the same steps: update the A record to the new IP, wait for DNS to spread, then run Certbot again on the new machine.

Ditulis oleh

Firdaus Safari Putra

Founder, PT FirKaizen Digital Solutions

Firdaus Safari Putra adalah founder PT FirKaizen Digital Solutions. Ia membangun dan mengoperasikan infrastruktur server di balik panduan ini, dan menulis berdasarkan apa yang benar-benar ia jalankan, uji, dan ukur — bukan teori.