How to Set Up Cloudflare DNS Servers with Your GoDaddy Domains

When it comes to buying online domains, GoDaddy is an obvious choice. Apart from being one of the world’s most notorious domain registrars and web hosting companies, GoDaddy additionally provides several valuable services, including important SSL certificates, website builder tools, or business email.

Right after getting a GoDaddy domain, you might want to manage your domain DNS using Cloudflare, so you can get the best of both worlds: make your website run faster and become more secure.

If you want to know how to link your GoDaddy domain to a Cloudflare DNS server, check below our step-by-step guide.

Register GoDaddy Domain Names

  • Choose your preferred authentication option.
  • Continue with the rest of the ‘Sign In’ process.
  • You can start looking for domains and add those you want to your cart.
  • You’ll then be prompted to add a payment method.
  • You’ll find all your purchased domains by clicking on your username > ‘My Products.’

Add DNS Records in Your Cloudflare Account

  • Go to your DNS setting.
  • Click on ‘Add site’ to add the domain name from GoDaddy.

  • Select a payment plan (you can always choose the free option that includes the basic and helpful Cloudflare features).

  • Add DNS records of your domains, then click ‘Continue’ → ‘Done’.
  • Check the ‘Nameservers’ buttons.
1. Type: A
   Name: api
   IPv4 address: [server-ip]
   
2. Type: A
   Name: @ (for root)
   IPv4 address: [server-ip]

  • Select the newly added site, go to ‘Rules’ and add the following Page Rules:
1. URL: http://site_name.ext/*
   Setting: Forwarding URL 
   Status Code: 301 - Permanent Redirect
   Destination URL: https://www.site_name.ext/$1
   
2. URL: http://*.site_name.ext/*
   Setting: Forwarding URL
   Status Code: 301 - Permanent Redirect
   Destination URL: https://$1.site_name.ext/$2
   
3. URL: https://site_name.ext/*
   Setting: Forwarding URL
   Status Code: 301 - Permanent Redirect
   Destination URL: https://www.site_name.ext/$1
  1. Go back to GoDaddy Console and change GoDaddy nameservers with the ones provided via Cloudflare.

Go to Domains → ‘Select domain’ ‘Manage DNS’‘Change Nameservers’ with the ones from Cloudflare.

*You’ll receive a notification that the update might take up to 48 hours, but usually, it takes only a few hours.

  • Go to ‘Nameservers’ section and click on ‘Change’.
  • Fill in the nameservers Cloudflare recommended and click on ‘Save’.

Last Step: Configure Nginx – Link GoDaddy Domains to Nginx Web Server

Connect to Nginx on server ubuntu instance to update config file:

ssh -i pem-file username@ip-address
sudo -i
docker exec -it nginx bash
cd /etc/nginx/conf.d
---open default.conf file and edit--- (you can use mc - can de installed using apt-get install mc)

Add the following configuration on default.conf file:

server {
  listen [nginx-port];
  server_name [frontend-redirect-url];
  location / {
    root /usr/share/nginx/html;
    index index.html index.htm;
    try_files $uri $uri/ /index.html;
  }
}
server {
  listen [nginx-port];
  server_name [api-redirect-base-url];
  location / {
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_pass http://[api-ip-address]:[api-port];
  }
}

Restart Nginx.

That’s it! You’ve now successfully connected your GoDaddy domain to Cloudflare!

By transitioning the nameservers from GoDaddy to Cloudflare, it’ll be Cloudflare that will manage your DNS records instead of GoDaddy. Still, your domain registrar and hosting resources will still be available in GoDaddy.