Cloudflare and Domain Setup for your Website

leangaurav
4 min readDec 12, 2019

Cloudflare is one of the many DNS providers. They provide different kind of plans, of which we will obviously go for the free one 😉.

This part is not useful if you are not planning to buy and/or link any domain with your website. For testing purpose you can access it via IP Address as well.

First thing we need is a Cloudflare Account. So go here and sign-up for one. Other wise login to your account. After signing-up make sure you verify your email. Further steps will be quite important so make sure you don’t miss anything.

Now login to your Cloudflare Account. You will find an option to add a site like this

Click on Add Site and enter your domain name (like example.com) and select the Free Plan and continue.

Now you will land up on something like

This is where you need the IP of the VM you created in GCP section. We will add here two kind of records: A and CNAME

The default one you can see is already of type A. In the first empty text box(name) enter your domain name and in the iPv4 address part add the external IP of your GCP machine. Make sure there are no typos as any changes done to these take a day or two to reflect completely. Click on Add Record.

Now change type from A to CNAME and in name type domain name with prefix www (like www.example.com) and in Domain Name section type only domain name (like example.com). Click Add Record and after adding record, click Continue at bottom.

On the next page you will get some instructions to add Cloudflare’s nameservers to your Domain Registrar. Instructions on how to change nameservers will depend on from where you have bought the domain. I will be showing you the steps for Google Domains. Once that is done, we will come back to this page. So keep it open.

After logging in to Google Domains, you will find your domains listed at home page and a Manage button towards right of each domain. Click on manage.

In the new page that loads, go to DNS section on the left hand panel.

Once there change the setting from Use Google Domains name servers to Use Custom name servers. Now you can enter the nameservers from cloudflare (click the + icon on right to add multiple nameservers). Click save.

Now go back to Cloudflare and click Done, check nameservers. Now this will take time, somewhere around 24hrs. Cloudflare will send you a mail once the DNS gets updated.

One last and very important step is to go to SSL/TLS section and then put a check on Full option for SSL/TLS encryption mode. Without this you may start getting a redirection error.

That’s it for this one. Wait for the mail to come and then head over to next section to finally deploy your wordpress website on the cloud. Here’s the link Deploy Wordpress, MySQL, Nginx Containers with HTTPS, SSL on GCP

Comment and share your experience or any issues you are facing.

--

--

leangaurav

Engineer | Trainer | writes about Practical Software Engineering | Find me on linkedin.com/in/leangaurav | Discuss anything topmate.io/leangaurav