Dev Talks

Web Development Tutorials

Connecting a GoDaddy Domain to a DigitalOcean Droplet
DevOps

Connecting a GoDaddy Domain to a DigitalOcean Droplet

Published on Dec 17, 2024

If you have a domain registered outside of your cloud or server provider. Pointing your domain to the server is easier than you can imagine. In very concise way, the process involves only two main steps:

First Step: Adding the domain to the host provider and adding necessary records to it.

Second Step: Changing the nameservers for your domain in the domain provider

That's it!

Those are the only two steps required for transferring domains, no matter what domain provider or server provider you'r dealing with.

In this article I'm going to go through this process step by step using an existing domain in Godaddy and a droplet with nginx installed on it on Digital Ocean.


If you don't have an account yet on digital ocean, you may signup through this link and get $200 credit.


Adding domain to Digital Ocean droplet

1- copy droplet public IP

Navigate to droplets and copy public IP of the droplet you want to connect domain to it.

2- Create Domain Route

Click on the Create green button on the top right and select Domains/DNS

create-domain-digitalocean.png 195.22 KB
This will open Networking page in the Domains tab Enter you domain name and select corresponding droplet and click Add Domain
digitalocean-networking.png 104.24 KB
3- Create domain records

Navigate to the domain route we have just created and create two A records in the HOSTNAME first A record Enter @ choose your droplet to redirect it to this will add a redirection for your basic domain ex: dev-talks.io.

Add a new A record in the HOSTNAME Enter www and choose same droplet this will add a record for www.dev-talks.io

digitalocean-records.png 63.85 KB
That's all we need to do on the host provider.


Update DNS setting in Godaddy

Go to your account on Godaddy open products and click on DNS in the domain settings, navigate to NameServers then click Change to update it to digital ocean nameservers like the following:

dodaddy-change-nameservers.png 179.9 KB

You may wait for couple of hours up to a day maybe and then you'r domain will be successfully transferred.


Another final step

If you'r using Nginx as we assumed you may also need to update server blocks to be able to work with the new domain

SSH into your droplet and update server block under /etc/nginx/sites-available

server {
    listen 80;
    server_name dev-talks.io www.dev-talks.io;

    root /var/www/dev-talks/public;
    index index.html index.htm index.php;

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

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # Adjust PHP version as per your setup
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}


Congrats!

We are done. That's all you need to do to connect your domain to your server.

Maybe in another article we may explain how to install ssl certificate and the whole sever setup and deployment. 

Happy Coding!👨‍💻

Stay tuned and pray for Palestine 🇵🇸