Russia
Learn how to connect a domain name to a VPS using DNS records, configure Nginx or Apache, activate HTTPS, verify DNS propagation, and troubleshoot common domain connection problems.
Written by Hamza
A virtual private server is normally identified by a public IP address, such as 192.0.2.10. Although visitors can sometimes access a website by entering its IP address, using a memorable domain name is more professional and practical.
Pointing a domain to a VPS means configuring the domain’s Domain Name System records so that requests for the domain are directed to the public IP address assigned to the server.
For example, when someone enters example.com in a browser, DNS translates that domain into the VPS IP address. The visitor’s browser then connects to the server, where Nginx, Apache, Caddy, or another web server delivers the website.
Connecting the DNS record is only the first part of the process. The VPS must also be configured to recognize the domain, accept web traffic, serve the correct website, and provide a valid HTTPS certificate.
When a visitor opens your domain, several systems work together. DNS identifies the destination IP address, the browser connects to the VPS, and the web server selects the website configuration associated with the requested domain.
You need access to the DNS management panel provided by your registrar or DNS hosting service.
Obtain the server’s public IPv4 address and, when available, its public IPv6 address.
Administrative access is needed to install and configure the web server and firewall.
Prepare your HTML files, application, CMS, container, or reverse-proxy destination.
The VPS provider normally displays the public IP address in the server dashboard, welcome email, control panel, or network settings.
You can also connect to the server through SSH and check its public IPv4 address with a command such as:
To check the public IPv6 address, use:
Sign in to the company that currently manages your domain’s DNS. This may be the domain registrar, a hosting company, or a dedicated DNS provider.
Look for a menu named DNS Management, DNS Zone, Manage Records, Zone Editor, or Advanced DNS.
Before changing anything, review the existing records. Deleting MX, TXT, DKIM, SPF, or verification records can interrupt email delivery and third-party services.
| Record | Purpose | Example Value |
|---|---|---|
| A | Connects a hostname to an IPv4 address. | 192.0.2.10 |
| AAAA | Connects a hostname to an IPv6 address. | 2001:db8::10 |
| CNAME | Makes one hostname an alias of another hostname. | www → example.com |
| MX | Controls where email for the domain is delivered. | mail.example.com |
| TXT | Stores verification, SPF, DKIM, DMARC, and other text data. | Service-specific value |
Create an A record that points the root domain to your VPS IPv4 address.
| Field | Recommended Value |
|---|---|
| Type | A |
| Name or Host | @ |
| Value or Points To | Your VPS IPv4 address |
| TTL | 300 seconds, automatic, or the provider default |
The root domain and the www version are separate DNS hostnames. Creating a record for example.com does not always make www.example.com work automatically.
A common configuration is to create a CNAME record for www:
Alternatively, you can create another A record for www and point it directly to the same VPS IPv4 address.
Create an AAAA record only when the VPS has a properly configured public IPv6 address and the web server is listening for IPv6 connections.
Do not create an AAAA record simply because the DNS panel allows it. Some visitors prefer IPv6 when both IPv4 and IPv6 records exist. If IPv6 is not working correctly, those visitors may experience connection failures even though the IPv4 website works.
These are two different operations. You normally do not need to change nameservers just to point a domain to a VPS.
| Action | What It Changes | When to Use It |
|---|---|---|
| Edit A or CNAME records | Changes where specific hostnames point. | Use this when the current DNS provider will continue managing the domain. |
| Change nameservers | Transfers DNS management to another provider. | Use this when moving the complete DNS zone to a new DNS service. |
DNS only directs traffic to the server. The VPS still needs a web server that listens on ports 80 and 443 and delivers the website.
After installation, enter the VPS IP address in a browser. The default Nginx page should appear when the service and firewall are correctly configured.
The VPS firewall and the provider-level network firewall must allow inbound traffic on the required ports.
| Port | Protocol | Purpose |
|---|---|---|
| 22 | TCP | SSH administration |
| 80 | TCP | Unencrypted HTTP traffic and certificate validation |
| 443 | TCP | Encrypted HTTPS traffic |
For a VPS using UFW, you can allow Nginx web traffic with:
Create a directory for the website:
Create a simple test page:
Add the following HTML:
Create the Nginx server block:
Add this configuration and replace example.com with your real domain:
root /var/www/example.com/html;
index index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
}
Enable the configuration:
When your VPS uses Apache instead of Nginx, create a virtual host configuration:
Add:
<Directory /var/www/example.com/html>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/example.com-error.log
CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined
</VirtualHost>
Enable the website and reload Apache:
DNS changes are not always visible immediately. Resolvers, internet providers, devices, and browsers may temporarily cache the previous DNS result.
Some changes appear within minutes, while others can take several hours. In certain situations, cached records or nameserver changes may take longer.
| DNS Change | Common Observation |
|---|---|
| A or CNAME record | May update within minutes but can remain cached longer. |
| Nameserver change | Can require more time because the authoritative DNS provider is changing. |
| Low TTL record | Usually refreshes more quickly after existing caches expire. |
Use DNS lookup tools to confirm that the domain returns the expected VPS IP address.
Confirm that the returned IP matches your VPS and that the HTTP response comes from the intended web server.
After the domain correctly resolves to the VPS and the website works over HTTP, install an SSL certificate to encrypt traffic.
Applications built with Node.js, Python, Docker, Java, Go, or another platform may run on an internal port such as 3000, 5000, or 8080.
In this situation, Nginx can act as a reverse proxy. Visitors connect to the standard web ports, while Nginx forwards requests to the internal application.
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
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;
}
}
You can use subdomains to host separate websites, applications, dashboards, APIs, control panels, or development environments.
| Hostname | DNS Record | Possible Purpose |
|---|---|---|
| app.example.com | A record to the VPS IP | Web application |
| api.example.com | A record to the VPS IP | API endpoint |
| blog.example.com | A or CNAME record | Blog or CMS installation |
| staging.example.com | A record to the VPS IP | Testing environment |
Each subdomain also needs a corresponding Nginx server block, Apache virtual host, reverse-proxy route, or application configuration.
Editing the website’s A record does not normally change email delivery when the MX and related TXT records remain intact.
However, deleting the complete DNS zone, replacing nameservers, or removing mail-related records can interrupt email.
A CDN or DNS-based reverse-proxy service can sit between visitors and your VPS. Supported web traffic is sent through the provider’s network before reaching the origin server.
Static files may be served closer to visitors, reducing requests to the VPS.
The service may provide visitor-facing HTTPS and additional certificate options.
Selected malicious requests, bots, or unusual traffic may be filtered.
The public DNS response may show the proxy network instead of the VPS address.
| Problem | Possible Cause | Recommended Check |
|---|---|---|
| Domain shows the old website | Cached DNS or an old proxy configuration | Check authoritative DNS records and test through another resolver. |
| Domain does not resolve | Missing record, incorrect nameservers, or expired domain | Verify registration status, nameservers, and the DNS zone. |
| Connection timed out | Firewall blocking ports 80 or 443 | Review the VPS firewall and provider network firewall. |
| Default Nginx page appears | Server block not enabled or server_name mismatch | Check enabled sites and the requested hostname. |
| www does not work | Missing www DNS record or web server alias | Create the www record and add www to server_name or ServerAlias. |
| SSL certificate request fails | Incorrect DNS, blocked port 80, or wrong web server configuration | Confirm DNS resolution and public HTTP accessibility. |
| Some visitors cannot connect | Broken IPv6 configuration | Test the AAAA record or temporarily remove it. |
| Email stops working | MX or TXT records were removed | Restore the original mail-related DNS records. |
An A record connects a domain or subdomain to the VPS IPv4 address. An AAAA record is used for a working IPv6 address.
Most DNS providers use the @ symbol for the root domain. For a subdomain, enter only the subdomain label, such as app, blog, api, or www.
Not usually. You can edit the A and CNAME records at the current DNS provider. Change nameservers only when you intentionally want another company to manage the complete DNS zone.
Some DNS changes become visible within minutes, while cached records may take several hours to refresh. Nameserver changes can take longer.
The DNS record may be incorrect, the change may still be cached, or the web server may not include the domain in its server_name or ServerAlias configuration.
Yes. Multiple domains can use the same VPS IP address. Nginx server blocks or Apache virtual hosts determine which website is served for each requested domain.
You need a stable public IP address assigned to the VPS. It does not normally need to be dedicated to only one website because modern web servers can host several domains on one IP.
For standard automated certificate validation, first point the domain to the VPS and confirm that the website is publicly reachable. Then request and install the SSL certificate.
Pointing a domain to a VPS involves more than adding an IP address to a DNS panel. A complete configuration connects the root domain and www hostname, prepares the web server, opens the required firewall ports, verifies DNS resolution, and activates HTTPS.
For a standard setup, create an A record that sends the root domain to the VPS IPv4 address and a CNAME record that sends www to the root domain. Add an AAAA record only when IPv6 connectivity has been properly configured and tested.
On the VPS, configure Nginx or Apache to recognize the requested domain, serve the correct website directory, and accept traffic on ports 80 and 443. Once the domain is resolving correctly, install an SSL certificate and redirect visitors to HTTPS.
Finally, test the root domain, www version, subdomains, IPv4, IPv6, SSL certificate, email records, firewall, and application logs. A careful verification process can prevent downtime, incorrect website routing, certificate errors, and broken email services.