Geekflare is supported by our audience. We may earn affiliate commissions from buying links on this site.
In Cloud Computing Last updated: September 6, 2022
Share on:
Invicti Web Application Security Scanner – the only solution that delivers automatic verification of vulnerabilities with Proof-Based Scanning™.

Procedure to enable Google Cloud CDN (Content Delivery Network) for your website.

In my previous post, I did a test and talked about how fast CDN is by Google. I covered briefly enabling, and many of you asked to explain in detail.


Cloud CDN by Google is a low-latency content delivery solution for small to enterprise businesses.

With more than 130 POP (point of presence) worldwide and accelerated content delivery using Google’s global premium network, make the fastest SSL CDN globally.

The latest report by CDNPerf showing Google Cloud CDN performs better than Azure, AKAMAI, Cloudflare, Fastly, and many others.


Some of the features of Google Cloud CDN:

  • HTTP/2 – it supports the latest HTTP protocol for better performance
  • Low latency – all contents are served through Anycast (single IP) worldwide.
  • Logging – it integrates with Stackdriver to provide detailed logging of a request, cache hit/miss.
  •  Purge cache instantly
  • Low cost


Wondering why pre-requisite?

Well, Google CDN only works with Google load balancer and cloud storage origins. This means if you are not hosting your application on GCP (Google Cloud Platform), then you can’t use their CDN.

In other words, it doesn’t support external origins yet. Simple.

So I assume you are hosting your application on GCP and ready to use a load balancer (LB) to use the cloud CDN.

You guessed it right; you can’t use VM as origin too. It can be enabled only on the load balancer.

Let’s get it started…


I’ve two VM running (one in Singapore and another in the US west). I want to load balance requests to both VM using an HTTP load balancer and activate CDN on it.

I need to do the following.

  • Create a health check
  • Create an instance group
  • Create a load balancer
  • Enable CDN

Creating a health check

A health check is essential for the load balancer to determine if the VM is healthy. When VM can’t respond to the query, then LB would mark that unhealthy and stop sending traffic.

  • Login to GCP and go to Health Checks under Compute Engine.
  • Click “Create a health check.”
  • Follow the wizard and enter the necessary information.
    • Protocol – select HTTP if your application hosted on VM will listen on port 80 and HTTPS for port 443
    • Request path – a working context root.
    • Health criteria – adjust as necessary
  • Click create

It will take a few seconds, and you will notice a newly created health check on the list. We will use this shortly.

Creating an instance group

The instance group is used in the load balancing setup. It’s called backend services for LB.

  • Go to Instance groups under Compute Engine.
  • Click “Create instance group.”
  • Follow the wizard to provide the necessary information.
    • Location – Select a single-zone as we are not going ahead with an auto-scaling option.
    • Zone – choose the zone where VM is running.
    • Group type – tick unmanaged instance group
    • VM instances – select the VM from the list.
  • Click Create

Repeat the steps for creating an instance group for another VM zone.

Now, we have two instance groups. Each mapped with the VM in the respective zone.

Creating a Load Balancer

  • Go to Load balancing under Network services
  • Click “Create load balancer.”
  • Select the “HTTP(S) load balancing.”
  • Enter the name of LB
  • Click on “Backend configuration.”
  • Click “Create a backend service.”
  • Enter the name of the backend services
  • Add both instances group which you created earlier as a backend
  • Select health check which you created previously
  • Session affinity – select if you want the session stickiness
  • Click create
  • Leave the default configuration in  “Host and path rules.” However, if you need conditional forwarding, then add as you need.
  • Click the frontend configuration and enter the name.
  • Select “create IP address” to get the static IP address. This is important as, by default, you will get ephemeral IP.
  • Protocol, IP version, and port leave it to the default.
  • Click Done
  • Click on review and finalize, and if you feel something is wrong, then change it else click “Create.”
  • Once created, you will notice newly created LB on the list.

This indicates LB is created. Let’s do some tests to ensure LB works.

So, I try to access LB frontend IP, and it’s a success!


You may also want to generate some loads to ensure traffic is routed to both the VMs. Google will forward requests to the nearest VM from the user’s geolocation.

In my scenario, traffic from Asia will go to VM in Singapore, and from America, it will go to US-West VM.

Activating Google Cloud CDN

And, finally, it’s time to enable the CDN.

  • Go to Cloud CDN under network services.
  • Click “Add origin.”
  • Select the load balancer from origin drop-down and click add
  • You should see newly created CDN on the list.

This concludes CDN is enabled on the load balancer.

Once you are satisfied with it, you can update your domain’s A record to load balancer global IP.

I hope this helps you. If you are looking to learn hands-on about Google Cloud Platform, then check out this Cloud Architecture with GCP course.

  • Chandan Kumar
    As the founder of Geekflare, I’ve helped millions to excel in the digital realm. Passionate about technology, I’m on a mission to explore the world and amplify growth for professionals and businesses alike.
Thanks to our Sponsors
More great readings on Cloud Computing
Power Your Business
Some of the tools and services to help your business grow.
  • Invicti uses the Proof-Based Scanning™ to automatically verify the identified vulnerabilities and generate actionable results within just hours.
    Try Invicti
  • Web scraping, residential proxy, proxy manager, web unlocker, search engine crawler, and all you need to collect web data.
    Try Brightdata
  • is an all-in-one work OS to help you manage projects, tasks, work, sales, CRM, operations, workflows, and more.
    Try Monday
  • Intruder is an online vulnerability scanner that finds cyber security weaknesses in your infrastructure, to avoid costly data breaches.
    Try Intruder