You can point your domain or subdomain to a VPS by creating an A record in your domain's DNS management panel. This works even when your domain and VPS are hosted by different providers.
For example, you can register a domain with Truehost and host your application on a Contabo VPS.
1. Access Your DNS Management
Log in to the provider managing your domain's DNS. This could be Truehost, Cloudflare, or another DNS provider.
If your domain uses Truehost nameservers, manage the DNS records in Truehost. If it uses another provider's nameservers, manage the records there instead.
2. Create an A Record
An A record connects your domain or subdomain to your VPS's public IPv4 address.
For example, suppose your domain is example.com and your VPS IP address is 123.45.67.89.
To point the root domain to your VPS, create this record:
- Type: A
- Host: @
- Value: 123.45.67.89
To point a subdomain, such as app.example.com, create this record:
- Type: A
- Host: app
- Value: 123.45.67.89
Save the record once you have entered the details.
3. Configure Your VPS
Creating the DNS record only directs traffic to your VPS. You must also configure your web server, such as Nginx or Apache, to serve your application using the correct domain or subdomain.
Ensure the necessary ports are open and configure an SSL certificate to enable HTTPS.
4. Verify the Connection
DNS changes may take a few minutes to propagate, although in some cases they can take up to 24-48 hours.
You can verify the connection by running the following command in your terminal:
nslookup app.example.com
Replace app.example.com with your actual domain or subdomain.
Important: You do not need to transfer your domain to your VPS provider. As long as you manage the correct DNS records and configure your VPS properly, your domain or subdomain can point to your application.
Top comments (0)