Setting up a load balancer

This page describes how to set up a load balancer to use Cloud Identity-Aware Proxy (Cloud IAP) with Compute Engine. If you're using Cloud IAP with Kubernetes Engine, the load balancer is typically configured by the Kubernetes Ingress controller. For more information, see enabling Cloud IAP for Kubernetes Engine.

Before you begin

Before you set up a load balancer, you'll need the following:

Setting up a load balancer in Compute Engine

To set up a load balancer in Compute Engine, your instances need to be in an instance group. This section describes how to create an instance group and then set up load balancing.

Creating an instance group

If you have instances in Compute Engine that aren't in an instance group, follow the steps below to add them to a group:

  1. Go to the Instance groups page.
    Go to the Compute Engine Instance groups page
  2. Click Create instance group.
  3. Under Group type, select Unmanaged instance group.
  4. Under VM instances, select each instance you want to add to the group.
    1. You can use the default values for other settings, or change them to the configuration you want.
  5. Click Create.

Setting up the load balancer

If your instances in Compute Engine are in an instance group, follow the steps below to set up the load balancer:

  1. Go to the Load balancing page.
    Go to the Load balancing page
  2. Click Create load balancer.
  3. Under HTTP(S) Load Balancing, click Start configuration.
  4. In the New HTTP(S) load balancer panel that appears, add a Name for your load balancer.
  5. Click Backend configuration, then create or select a backend service. If you create a new backend service, follow the steps below:

    1. Add a Name for your backend service.
    2. Under Protocol, select HTTP or HTTPS. For HTTPS, each instance must be configured to serve SSL and have a certificate installed. However, you can use any certificate, including a self-signed one.
    3. In Backends > New Backend > Instance group, select the instance group you want to use.
    4. Don't enable Cloud CDN. It isn't supported for Cloud IAP. You can keep the other default settings, or customise however you want.
    5. In Health check > Create a health check, add a Name for your health check.

      Note that Compute Engine and Kubernetes Engine health checks don't include JWT headers and Cloud IAP doesn't handle health checks. If your health check returns access errors, make sure that you have it configured correctly in the GCP Console and that your JWT header validation whitelists the health check path. For more information, see Create a health check exception.

  6. In Host and path rules, you can keep the default settings.

  7. Click Frontend configuration, then follow the steps bellow:
    1. Under Protocol, select HTTPS.
    2. Under Certificate > Create a new certificate, add a Name for your certificate, then add the Public key certificate and other details as needed.
  8. When you're finished configuring the load balancer, click Create.
  9. On the Load balancing screen, note the IP:Port for your load balancer. Register your domain to the load balancer to route traffic through the load balancer.

Best practices


  • Make sure all requests to Compute Engine or Kubernetes Engine are routed through the load balancer:
    • Configure a firewall rule to allow health checking and make sure that all traffic to your Virtual Machine (VM) is from a Google Front End (GFE) IP.
    • For additional protection, check the source IP of requests in your app to make sure they're from the same IP range that the firewall rule allows.
  • In the GCP Console, Cloud IAP displays an error or warning if your firewall rules appear to be set up incorrectly. The Cloud IAP GCP Console doesn't detect which VM is used for each service, so the firewall analysis doesn't include advanced features like non-default networks and firewall rule tags. To bypass this analysis, enable Cloud IAP through the gcloud compute backend-services update command.

What's next

Was this page helpful? Let us know how we did:

Send feedback about...

Identity-Aware Proxy Documentation