Hosting SSL protected WordPress site in Google Cloud – a complete guide

This guide covers following topics:

  • Setting up a WordPress vm in GCP ( Google Cloud Platform)
  • Adding a bought domain to Cloudflare
  • Configuring Flexible SSL with WordPress and Cloudflare

Setting up a WordPress VM in GCP ( Google Cloud Platform) – the easy part

Requirements: A working Google Cloud account. If you don’t have any, you can get a trial.

Go to the Cloud Console -> Market Place and search for “wordpress”. You would want to find “Google Click to Deploy” WordPress app of Virtual Machine type. Here is the direct link if you can’t locate: GCP WordPress vm

Clicking it will open a configuration page for the VM. Initially we will start with a small instance (1 shared vCPU , 1.7 GB RAM) and later convert to a micro instance in USA as it will be free to host. Check more about GCP always Free here.  it doesn’t allow to select micro instance directly if you are deploying from market place.

Here is the complete setting.

Google Cloud wordpress VM configuration

Make sure to check “Allow Https traffic”.

Deployment should take about 2-3 minutes. Once finished, you will be given with mysql, wordpress admin user/passwords. You can find it back again by going to GCP Menu -> Deployment Manager -> Deployments. It will only show deployments from Marketplace.

vm deployed

Next, we will need to allocate a static IP address for the VM. This is required because we will need it for CloudFlare , also if you restart your VM , it will be assigned new IP address otherwise. We need to avoid that.

Go to GCP Menu -> VPC Network-> External IP addresses. Look for the newly created VM and change the IP address from Ephemeral to static.

Static IP has been locked in, let’s change VM to Micro instance. Go to GCP Menu -> Compute Engine -> Vm Instances. Click on your newly created vm. and STOP it. Once stopped you will be able to modify the instance size. Choose macro instance now. And start the Vm again.


Adding a bought domain to Cloudflare

I will be using Dreamhost for domain registering but you can use any registrar of you liking. At the moment Dreamhost has a sale for .club domains which only costs $0.99.  I have gone through the buying process to buy

Once domain has been sorted out, we will have to add DNS hosting only for our domain. Add DNS only hostings.

and then

Once added, you should something like below:

Now head over to Cloudflare. Create an account if you don’t have one. It’s free.

Add a new site from “Add Site” button and add ( in your case, yours).

Once added you will see:

Select Next and Choose the free plan.

And confirm the plan. Next we need to use Cloudflare’s Nameservers for the new domain.

Let’s go back to Dreamhost and update the nameservers to “” and ““.

and click “Set these nameservers for”. It will take up to 30 minutes for the change to be made, and then it can take a day or more for the new DNS information to propagate across the Internet.

Now back to Cloudflare, click “Recheck Nameservers” and wait. You will receive and email from Cloudflare once the site has been added. It might take few hours.

Next step is to configure WordPress IP with new domain. Go to Cloudflare site -> DNS (area). We will all an A record and a CNAME record. Add following entries:

Once done, your domain should point to the GCP WordPress VM now.

Let’s update the site name in WordPress.  Go to wordpress settings and update “WordPress Address” and “Site Address” to new domain name.

Once done, you will be logged out and need log in again with the new domain name. Now you can browse your WordPress instance with your newly bought domain name


Configuring Flexible SSL with WordPress and Cloudflare – the good part

The most important part is to protect your site with an SSL certificate but those are damn expensive. However, you can use a free one provided by Cloudflare. And it’s easy to configure.

First, we will need to install a WordPress plugin for SSL to configure flexible SSL of Cloudflare. Go ahead and install a plugin called : “CloudFlare Flexible SSL“.

Once installed, head back to Cloudflare and let’s switch on Flexible SSL. You can do this by going to “Crypto” tab and switching on “SSL” to “Flexible”. In most cases it would be by default.

Head down a little bit on the same page and look for “Always use HTTPS” and turn it on.

But wait, if you browse the site, it won’t load properly and you will see it messed up. Don’t worry.

This is because most of the content is not served over https. This can be fixed by another plugin – “SSL Insecure Content Fixer“.

First, switch off “always on HTTPS” in Cloudflare and turn off the SSL for wordpress.  and Install – “SSL Insecure Content Fixer“.
Go to plugin’s settings page. Set Http Detection as “HTTP_X_FORWARDED_PROTO”

And that’s it. Switch “Flexible SSL” and “Always HTTPS” on in Cloudflare and browse the site.

Make sure NOT to change “WordPress Address” and “Site Address” to https one.



3 thoughts on “Hosting SSL protected WordPress site in Google Cloud – a complete guide

    1. Have you tried the inbuilt import export in WordPress? I recently moved my site to google cloud and it did the trick.

      If not, there are a ton of WordPress plugins that can do what you desire

      1. This is real bad advice. It will only import/export the posts. Your theme and so on won’t be exported.

Leave a Reply

Your email address will not be published. Required fields are marked *