Registering Google Domains to Google Cloud WordPress

This is part 2 of a three-part guide to setting up and configuring WordPress hosted on Google Cloud Platform and registered with a Google Domain URL. Readers should make sure their WordPress instance is running and behaving properly using GCP and have WordPress admin access before attempting this guide. You can read part 1 here.


To prevent bulking of a single article, I separated this holistic guide into three separate parts. Feel free to jump to the next article when you are done with this one. For your convenience, the guides are outlined below:

 

How To Deploy WordPress Using Google Cloud Click-to-Deploy
Registering Google Domains to Google Cloud WordPress (Current Post)
Secure your WordPress Using HTTPS

 

 

 

 

 

 

 


Benefits of Using Google Domains

Google Domains is a relatively new service compared to other hosting services such as GoDaddy and HostGator which provides some features that are convenient for regular Google account holders. While discounts and promotions are seldom for Google Domains (this makes Google Domains usually more expensive than other hosting services at the most basic level), it comes with many options included in the base price. You can read about the features on the Google Domains landing page, but the two good selling points that come packaged are the masking of WHOIS information as well as the domains being hosted behind Google’s fast and reliable data infrastructure. Although I haven’t used other domain hosting platforms, Google Domains’s UI is also very straightforward and simple, making things like DNS setting very easy.

Continue on for the step-by-step guide.

Pre-Requisites

  • GCP account with running WordPress instance, and administrator console access.
  • Have your instance IP address on hand – you will need it to configure DNS records.
  • Google Domains, with a domain purchased and ready for setup:
Google Domain Dashboard

Setting IP Address of VM Instance to Static

Make sure that your instance is always assigned the same IP address. Failure to do will may result in GCP assigning the instance a different IP, which will break the DNS configurations you will make further down this guide and result in the domain not being able to resolve to your WordPress instance. This is a rather important step that should not be overlooked.

To set your instance to static, open up your GCP account and set it to your WordPress site’s project. At the center of the header navigation is a search bar – type in “External IP addresses” and select the “External IP addresses – VPC Network” option:

Figure 1-1 : Configure External IP Address

Set the IP address to static and confirm in the popup window that appears. Enter a name for the external IP address – it can be anything you like:

Figure 1-2 : Setting External Address as Static IP

Configuring Google Cloud Platform’s Cloud DNS Settings

At the center of the header navigation is a search bar – type in “Cloud DNS” and select the “Cloud DNS – Network Services” option:

Figure 2-1 : Search for Cloud DNS

Since I already created my DNS zone, an entry is visible as shown. For you, however, a prompt may appear for you in the middle of the window to create a new zone. If so, click on that button, or refer to image below to start setting a new DNS zone.

Figure 2-2 : Create New DNS Zone

You will be brought to the following screen:

Figure 2-3 : Configure DNS Zone Information
  • Zone Name can be anything you want as long as it complies with the naming convention (A prompt will shout at you if you give a bad name!).
  • DNS name should be the domain you registered with Google Domains (in this case, example123.net). Do not include “http://” nor “www.” here.
  • Click Create

Now you will add TWO record sets – one for linking the domain to your instance’s IP address, and another for mapping www. subdomain.
Start with the “A” record.

Figure 2-4 : Add New Record Set

 

Figure 2-5 : Configure “A” Record Set
  • Make sure Resource Record Type is “A” (should be default).
  • For IPv4 Address, set this equal to your WordPress instance’s IP Address.
  • Click Create.

You should return back to the DNS Records setting page, and a new entry for “A” record should now be visible. To configure the “CNAME” record, Follow Figure 2-5 and click on “Add Record Set” again.

Figure 2-6 : Configure “CNAME” Record Set
  • For DNS Name, add “www” to the field as shown above.
  • Set Resource Record Type to “CNAME”.
  • For Canonical name, set this equal to your Google Domains’s URL.
  • Click Create.

You should now have a total of FOUR entries in the Zone Details page: “A”, “NS”, “SOA”, and “CNAME”.

One piece of information you must note from here are the NS values, highlighted below:

Figure 2-7 : Note the Custom Name Servers

GCP and Google Domains use DIFFERENT name servers, and so we will need to override the Google Domains’s DNS settings to reflect the values shown here. How to do that is detailed in the next section.

Configuring Google Domain’s Cloud DNS Settings

On the same or separate browser window, navigate to Google Domains Console and verify that your domain exists in the dashboard.
Under the DNS column, click on the icon corresponding to the domain you wish to change DNS configurations for:

Figure 3-1 : Configure DNS on Google Domains

 

Figure 3-2 : Configure Custom Name Servers

Select “Use custom name servers” and fill in four entries corresponding to the DNS name servers you found in the GCP Cloud DNS page (refer to Figure 2-7). Click Save to save the settings. When you’re done, scroll down until you see the section labelled “Custom resource records”. Here you will make the same settings you did on the GCP Cloud DNS settings section. Refer to the figure below for guidelines – note that “@” is synonymous to your domain name.

** There may be a warning that shows up stating “It looks like you’ve changed your name servers…”. You may ignore it.

Figure 3-3 : Configure Google Domains DNS Record Sets

Once you are done, take a 5-minute breather (grab a coffee!) and then you may optionally check to see whether your domain is registered successfully across DNS servers worldwide. If everything goes smoothly then you should see your domain being registered to the IP address of your WordPress site and reflected in the DNS Checker results. The site I use is DNS Checker.

Configuring SiteURL and Host Name on WordPress Admin Console

On another browser window, navigate to “http://##DOMAIN_NAME##.com/wp-admin/options-general.php” and provide your admin credentials if necessary. You should be brought to the General Settings page and, if you deployed the Click-to-Deploy version of WordPress, you should see the two fields “WordPress Address (URL)” and “Site Address (URL)“. Fill it with your registered domain (see below for reference), and click “Save Changes” at the bottom of the page.

Figure 4-1 : Set Domain on WordPress General Settings

Confirming Domain is Successfully Registered

Test that you are able to connect to your WordPress site by trying any or all of the following combinations:

  • domain.com
  • www.domain.com
  • http://domain.com
  • http://www.domain.com

If you could successfully navigate to your site via the options above, congratulations, you have finished registering your Google domain with your GCP WordPress instance!

Next Steps

Now everything is set and ready to go for online readers to navigate to your site. However, one problems remains which is that your WordPress site is not secured under the HTTPS protocol yet. To do that, you will need to to create and register a certificate on your WordPress VM instance and configure Apache settings to redirect all HTTP traffic to HTTPS. Having HTTPS provides a security advantage, SEO advantage, and gives readers piece of mind knowing that your site is committed to a decent level of security.