Short answer
To point a domain to a VDS, add an A record for @ and www in the domain’s DNS panel with the server’s IPv4 address; if IPv6 works on the server, add an AAAA record too. Once the record has propagated, give Nginx a server block for the domain, open ports 80 and 443, and get a free SSL certificate from Let’s Encrypt with certbot.
The commands are for Ubuntu and Debian; differences on AlmaLinux and Rocky Linux are noted in the relevant step. The examples use the domain example.com, the IPv4 address 203.0.113.10 and the IPv6 address 2001:db8::10. Replace them with your own values.
What do you need before you start?
- Access to the panel where the domain’s DNS records live. Records are edited wherever the domain’s nameservers point. If dig NS example.com +short returns your registrar’s servers, use the registrar’s panel; if it returns a separate DNS service such as Cloudflare, use that service.
- The server’s public IPv4 address. It is the address other than 127.0.0.1 in the output of ip -4 addr show. Every WeServer Turkey VDS plan includes 1 IPv4 address.
- A working IPv6 address on the server if you plan to use IPv6. IPv6 Subnet VDS plans come with a /64 or /48 subnet; how to set the address up on the server is covered in “How to configure IPv6 on an Ubuntu server with netplan”.
- SSH access to the server as root or a user with sudo. The login steps are in “How to connect to a VDS via SSH”.
How do you add A and AAAA records?
Open the screen for adding a new record in your DNS panel and enter the records below. The @ in the Name (Host) field stands for the domain itself. Some panels append the domain to whatever you type in that field: enter www.example.com and the record becomes www.example.com.example.com, so type just www.
- A record: Name @, Value 203.0.113.10. Points example.com to the server.
- www record: Name www, type CNAME, Value example.com. A second A record with the same IP works as well. You cannot put a CNAME on the bare domain (@): the DNS standard (RFC 1034) does not allow a name with a CNAME to hold other records.
- AAAA record: Name @ (plus one for www if www is not a CNAME), Value 2001:db8::10. Do not add it if IPv6 does not work on the server. Visitors with IPv6 and Let’s Encrypt validation try this address first; if it does not answer, the site loads slowly or not at all for some visitors, and the certificate may fail to issue.
- TTL: anything between 300 and 3600 seconds is fine. If you are moving the site from another server, lower the old record’s TTL to 300 a day in advance so the IP change spreads faster.
Has the DNS record propagated? How do you check?
A newly added record usually shows up within minutes. If you changed an existing record, the visitor’s DNS resolver keeps the old answer cached until its TTL runs out; with a TTL of 3600 that is up to about an hour. Changing nameservers takes longer, because for extensions like .com the NS records have a TTL of two days.
- dig +short example.com A and dig +short example.com AAAA: the addresses your own computer’s resolver sees.
- dig +short example.com A @1.1.1.1 and dig +short example.com A @8.8.8.8: the answer from public resolvers. If both return 203.0.113.10, the record has propagated.
- dig +short example.com A @<nameserver name>: the source of the record. If the old address shows up here too, you edited the record in the wrong panel.
- On Windows, nslookup example.com 1.1.1.1 does the same job. If your computer keeps showing the old address, clear the local cache with ipconfig /flushdns.
How do you set up the site for the domain in Nginx?
Once the domain points to the server, Nginx needs to know where to send requests for that name. On Ubuntu and Debian:
- 1. Install Nginx: apt update && apt install nginx. After that, opening the server’s IP in a browser shows the “Welcome to nginx!” page.
- 2. Create the site directory: mkdir -p /var/www/example.com. Put your files there; a simple index.html is enough for a test.
- 3. Create /etc/nginx/sites-available/example.com with this block: server { listen 80; listen [::]:80; server_name example.com www.example.com; root /var/www/example.com; index index.html; }
- 4. Enable the site: ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/. nginx -t tests the configuration; once you see “syntax is ok” and “test is successful”, run systemctl reload nginx.
- 5. Open ports 80 and 443 in the firewall: ufw allow 80/tcp and ufw allow 443/tcp. Setting up ufw in the first place is covered in “How to secure a new VDS: first security steps”.
How do you configure Nginx when the app runs on a port?
An app running in Node.js, Python or Docker usually listens on a port such as 3000 or 8080. In that case, replace the root and index lines with a location block that passes requests to the app: location / { proxy_pass http://127.0.0.1:3000; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; }. Put your app’s port in place of 3000. You do not need to open the app’s port in the firewall: visitors arrive on 80 and 443, and Nginx forwards the request inside the server.
AlmaLinux and Rocky Linux have no sites-available directory. The block goes into /etc/nginx/conf.d/example.com.conf and needs no separate enabling step. Open the ports with firewall-cmd --permanent --add-service=http --add-service=https followed by firewall-cmd --reload. With SELinux enabled, Nginx also needs setsebool -P httpd_can_network_connect 1 to connect to a local port; without it, proxied requests return 502.
How do you install a free SSL certificate? (Let’s Encrypt and certbot)
Let’s Encrypt issues free TLS certificates. certbot obtains the certificate, adds it to the Nginx configuration and schedules renewal. Before issuing, Let’s Encrypt checks that the domain points to this server by requesting a validation file over port 80. So the DNS record must have propagated and Nginx must already answer for the domain.
- Install: apt install certbot python3-certbot-nginx. On AlmaLinux and Rocky Linux, run dnf install epel-release first, then dnf install certbot python3-certbot-nginx.
- Certificate: certbot --nginx -d example.com -d www.example.com. The first run asks for an email address and acceptance of the terms of service. certbot adds a 443 listener and the certificate paths to the server block, plus a rule redirecting HTTP to HTTPS (older versions ask about the redirect).
- Check: https://example.com should open in the browser with the padlock icon, and curl -I https://example.com should return 200 or 301.
- Renewal: Let’s Encrypt certificates are short-lived. The systemd timer that ships with the package renews them before they expire. systemctl list-timers | grep certbot shows the timer is in place, and certbot renew --dry-run shows renewal will go through without errors.
What errors come up when pointing a domain, and how do you fix them?
- The browser says “DNS_PROBE_FINISHED_NXDOMAIN” or “This site can’t be reached”. Cause: the record was added in a panel the domain does not use, or the name is wrong (such as www.example.com.example.com). Fix: find the right panel with dig NS example.com +short and check the record there.
- The domain loads but shows the “Welcome to nginx!” page. Cause: the request falls through to the default site; server_name does not match the domain, or the new site is not linked under sites-enabled. Fix: list the configured names with nginx -T | grep server_name, create the link and run systemctl reload nginx.
- certbot says “Timeout during connect (likely firewall problem)”. Cause: port 80 is closed from the outside. Fix: ufw allow 80/tcp, then confirm from another machine with curl -I http://example.com.
- certbot says “DNS problem: NXDOMAIN looking up A for www.example.com”. Cause: there is no www record yet, or it has not propagated. Fix: add the record and wait until dig shows it, or drop -d www.example.com from the command.
- certbot reports a 404 for the validation file, or a response from another server. Cause: the AAAA record points to an old address, Nginx does not listen on IPv6, or DNS still returns the old IP. Fix: check the address with dig AAAA example.com +short; make sure the server block has listen [::]:80, and delete the AAAA record if you do not use IPv6.
- The browser says “ERR_TOO_MANY_REDIRECTS”. Cause: the domain is behind the Cloudflare proxy with SSL mode set to Flexible, and Nginx redirects HTTP to HTTPS; Cloudflare reaches the server over HTTP, so the request loops. Fix: set the SSL/TLS mode in Cloudflare to Full (strict).
- The www address shows “NET::ERR_CERT_COMMON_NAME_INVALID”. Cause: the certificate was issued for example.com only. Fix: add www with certbot --nginx -d example.com -d www.example.com --expand.
Frequently asked questions
Will pointing my domain to a VDS affect my email? Not if you only change the A and AAAA records, because email runs on MX and TXT (SPF, DKIM) records. If you are changing nameservers, copy those records to the new DNS service first. If the server will send email, also see “What is a reverse DNS (PTR) record and why does a server need one?”.
Can one VDS host several domains? Yes. Each domain gets its own server block, and you run certbot for each one. Nginx routes each request to the right site by its Host header, or by SNI over HTTPS, so all of them can share one IPv4 address.
Should I use www or the bare domain? Both work. Pick one as the main address and 301-redirect the other to it. To send www to the bare domain, for example, put return 301 https://example.com$request_uri; in the server block for www.example.com.
When does the SSL certificate renew? The timer installed by the certbot package renews it before it expires, and the --nginx plugin reloads Nginx. There is nothing to do by hand; running certbot renew --dry-run now and then is enough to confirm renewal works.
How do I connect a domain on a Windows Server VDS? The DNS steps are the same. In IIS, add example.com and www.example.com as host names on the site’s Bindings screen. For a free certificate you can use win-acme, an ACME client that runs on Windows; ports 80 and 443 must be open in Windows Firewall.
