Set up a global external Application Load Balancer with an external backend Stay organized with collections Save and categorize content based on your preferences.
This guide uses an example to teach the fundamentals of using an externalbackend (sometimes called acustom origin) with a global external Application Load Balancer. Anexternal backend is an endpoint that is external to Google Cloud. When you usean external backend with a global external Application Load Balancer, you can improve performanceby using Cloud CDN caching.
The guide shows you how to configure a global external Application Load Balancer with aCloud CDN-enabled backend service that proxies requests to anexternal backend server.
Before following this guide, familiarize yourself with theInternet NEGoverview documentation,including thelimitations.The following architecture diagram shows a global external Application Load Balancer frontend withan external backend.
Permissions
To follow this guide, you need to create an internet NEG and create or modify anexternal Application Load Balancer in a project. You should be either a projectOwner orEditor (roles/owner orroles/editor), oryou should have both of the followingCompute Engine IAMroles.
| Task | Required role |
|---|---|
| Create and modify load balancer components | Compute Network Admin ( roles/compute.networkAdmin) |
| Create and modify NEGs | Compute Instance Admin ( roles/compute.instanceAdmin) |
Optional: Use BYOIP addresses
With bring your own IP (BYOIP), you can import your own public addresses toGoogle Cloud to use the addresses with Google Cloud resources. Forexample, if you import your own IPv4 addresses, you can assign one to theforwarding rule when you configure your load balancer. When you follow theinstructions in this document tocreate the load balancer, provide the BYOIP address as theIP address.
For more information about using BYOIP, seeBring your own IP addresses.
Set up your external backend environment outside Google Cloud
To set up your environment, see the following sections.
Configure network endpoints
Configure a network endpoint to expose your external backend toGoogle Cloud. Make sure that the endpoint—either an IP:Port combinationor a fully-qualified domain name (FQDN) and port—is reachable over theinternet. This endpoint is later referenced from the internet NEG.
For detailed configuration requirements for internet NEG endpoints, see theInternet NEGs overview.
Allow the external backend to receive traffic from Google Cloud
To allow requests from Google Cloud to reach your external backend, youmust allowlist the IP address ranges that Google uses to send requests toexternal backends. To look up the IP addresses that need to be allowed to sendtraffic to your external backends, query the_cloud-eoips.googleusercontent.com DNS TXT record by using a tool such asdig ornslookup.
Examples:
Run the following
nslookupcommand:nslookup -q=TXT _cloud-eoips.googleusercontent.com 8.8.8.8
The output looks like the following:
Non-authoritative answer:_cloud-eoips.googleusercontent.com text = "v=spf1 ip4:34.96.0.0/20 ip4:34.127.192.0/18 ~all"
Note the CIDR ranges following
ip4:and ensure that these ranges are allowedby the firewall rules or cloud access control lists (ACLs) configured on yourexternal backend.Run the following
digcommand:dig TXT _cloud-eoips.googleusercontent.com | grep -Eo 'ip4:[^ ]+' | cut -d':' -f2
The output contains two IP address ranges, as follows:
34.96.0.0/2034.127.192.0/18
Set up your Google Cloud environment
Create the global external Application Load Balancer with an internet NEG backend.
Reserve an external IP address
Reserve a global static external IP address that clients use to reach yourapplication.
Note: This step is required for this example, and recommended in general.Reserving an IP address is also essential if you are using acustom domain for your external backend (also required for Google-managed SSLcertificates). With a custom domain, you must update your DNS recordsto point your domain to this IP address.Console
In the Google Cloud console, go to theExternal IP addresses page.
ClickReserve external static address to reserve an IPv4 address.
Enter a name.
ForNetwork Service Tier, selectPremium.
ForIP version, selectIPv4.
ForType, selectGlobal.
ClickReserve.
gcloud
gcloud compute addresses createLB_IP_ADDRESS_NAME \ --network-tier=PREMIUM \ --ip-version=IPV4 \ --global
Note the IPv4 address that was reserved:
gcloud compute addresses describeLB_IP_ADDRESS_NAME \ --format="get(address)" \ --global
Set up the internet NEG
Console
In the Google Cloud console, go to theNetwork endpoint groups page.
ClickCreate network endpoint group.
Enter a name.
ForNetwork endpoint group type, selectNetworkendpoint group (Internet).
ForDefault port, enter
443.ForNew network endpoint, selectFully qualified domain name andport.
Enter theFully qualified domain name.
ForPort type, selectDefault, and verify thatPortnumber is
443.ClickCreate.
gcloud
Create an internet NEG, and set the
--network-endpoint-typetointernet-fqdn-port(the hostname and port where your external backendcan be reached):gcloud compute network-endpoint-groups createINTERNET_NEG_NAME \ --network-endpoint-type="internet-fqdn-port" \ --global
Add your endpoint to the NEG. If a port isn't specified, the portselection defaults to port
80(HTTP) or443(HTTPS; HTTP/2) dependingon the protocol configured in the backend service. Make sure to includethe--globalflag:gcloud compute network-endpoint-groups updateINTERNET_NEG_NAME \ --add-endpoint="fqdn=FULLY_QUALIFIED_DOMAIN_NAME,port=443" \ --global
Create the load balancer
Console
Select the load balancer type
In the Google Cloud console, go to theLoad balancing page.
- ClickCreate load balancer.
- ForType of load balancer, selectApplication Load Balancer (HTTP/HTTPS) and clickNext.
- ForPublic facing or internal, selectPublic facing (external) and clickNext.
- ForGlobal or single region deployment, selectBest for global workloads and clickNext.
- ForLoad balancer generation, selectGlobal external Application Load Balancer and clickNext.
- ClickConfigure.
Frontend configuration
- ClickFrontend configuration.
- Enter a name.
To create anHTTPS load balancer, you must have an SSL certificate.We recommend using a Google-managed certificate.
Verify that the following options are configured with these values.
Property Value (type a value or select an option as specified) Protocol HTTPS Network Service Tier Premium IP version IPv4 IP address Select the IP address created in theReserve an external IP address step. Port 443 Optional: HTTP keepalive timeout Enter a timeout value from 5 to 1200 seconds. The default value is 610 seconds. Certificate Select an existing SSL certificate or create a new certificate.
To create an HTTPS load balancer, you must have anSSL certificate resource to use in the HTTPS proxy. You can create an SSL certificate resource by using either a Google-managed SSL certificate or a self-managed SSL certificate.
To create a Google-managed certificate, you must have a domain. The domain's A record must resolve to the IP address of the load balancer (in this example,
example-ip). We recommend using Google-managed certificates because Google Cloud obtains, manages, and renews these certificates automatically. If you don't have a domain, you can use a self-signed SSL certificate for testing.Optional: Enable HTTP to HTTPS Redirect Use this checkbox to enable HTTP to HTTPS redirects.
Enabling this checkbox creates an additional partial HTTP load balancer that uses the same IP address as your HTTPS load balancer and redirects HTTP requests to your load balancer's HTTPS frontend.
This checkbox can only be selected when the HTTPS protocol is selected and a reserved IP address is used.
If you want to test this process without setting up an SSL certificateresource (or a domain as required by Google-managed certificates), youcan set up an HTTP load balancer.
To create anHTTP load balancer, verify that the following options areconfigured with these values:
Property Value (type a value or select an option as specified) Protocol HTTP Network Service Tier Premium IP version IPv4 IP address Select the IP address created in theReserve an external IP address step. Port 80 Optional: HTTP keepalive timeout Enter a timeout value from 5 to 1200 seconds. The default value is 610 seconds. ClickDone.
Backend configuration
- ClickBackend configuration.
- ClickBackend services and backend buckets.
- ClickCreate a backend service.
- Enter a name.
- ForBackend type, selectInternet network endpoint group.
- ForProtocol, select the protocol that you intend to use from theload balancer to the internet NEG. For this example, selectHTTP/2.
- ForBackends, in theNew backend window, select the internet NEGcreated in the previous step.
- ClickCreate.
Review and finalize
- ClickReview and finalize.
- If everything looks correct, clickCreate.
gcloud
- Create a backend service:
gcloud compute backend-services createBACKEND_SERVICE \ --load-balancing-scheme=EXTERNAL_MANAGED \ --global
- Add the internet NEG to the backend service:
gcloud compute backend-services add-backendBACKEND_SERVICE \ --network-endpoint-group=INTERNET_NEG_NAME \ --global-network-endpoint-group \ --global
- Create a URL map to route incoming requests to the backend service:
gcloud compute url-maps createURL_MAP_NAME \ --default-service=BACKEND_SERVICE \ --global
Perform this step only if you want to create an HTTPS load balancer. This step is not required for HTTP load balancers.
To create an HTTPS load balancer, you must have anSSL certificate resource to use in the HTTPS target proxy. You can create an SSL certificate resource by using either a Google-managed SSL certificate or a self-managed SSL certificate. We recommend using Google-managed certificates because Google Cloud obtains, manages, and renews these certificates automatically.
To create a Google-managed certificate,you must have a domain. If you don't have a domain, you can use a self-managed SSL certificate for testing.
To create a Google-managed SSL certificate resource: To create a self-managed SSL certificate resource:gcloud compute ssl-certificates createSSL_CERTIFICATE_NAME \ --domainsDOMAIN
gcloud compute ssl-certificates createSSL_CERTIFICATE_NAME \ --certificateCRT_FILE_PATH \ --private-keyKEY_FILE_PATH
Create a target HTTP(S) proxy to route requests to your URL map.
For an HTTP load balancer, create an HTTP target proxy:
gcloud compute target-http-proxies createTARGET_HTTP_PROXY_NAME \ --url-map=URL_MAP_NAME \ --global
For an HTTPS load balancer, create an HTTPS target proxy. The proxy is the portion of the load balancer that holds the SSL certificate for HTTPS Load Balancing, so you also load your certificate in this step.
gcloud compute target-https-proxies createTARGET_HTTPS_PROXY_NAME \ --ssl-certificates=SSL_CERTIFICATE_NAME \ --url-map=URL_MAP_NAME \ --global
Replace the following:
TARGET_HTTP_PROXY_NAME: the name of the target HTTP proxy.TARGET_HTTPS_PROXY_NAME: the name of the target HTTPS proxy.SSL_CERTIFICATE_NAME: the name of the SSL certificate.URL_MAP_NAME: the name of the URL map.
--http-keep-alive-timeout-secoption. The timeout value must be between 5 to 1200 seconds. The default value is 610 seconds.Create a forwarding rule to route incoming requests to the proxy.
For an HTTP load balancer:
gcloud compute forwarding-rules createHTTP_FORWARDING_RULE_NAME \ --load-balancing-scheme=EXTERNAL_MANAGED \ --network-tier=PREMIUM \ --address=LB_IP_ADDRESS_NAME \ --target-http-proxy=TARGET_HTTP_PROXY_NAME \ --global \ --ports=80
For an HTTPS load balancer:
gcloud compute forwarding-rules createHTTPS_FORWARDING_RULE_NAME \ --load-balancing-scheme=EXTERNAL_MANAGED \ --network-tier=PREMIUM \ --address=LB_IP_ADDRESS_NAME \ --target-https-proxy=TARGET_HTTPS_PROXY_NAME \ --global \ --ports=443
Connect your domain to your load balancer
After the load balancer is created, note the IP address that is associated withthe load balancer—for example,30.90.80.100. To point your domain to yourload balancer, create anA record by using your domain registration service. Ifyou added multiple domains to your SSL certificate, you must add anA recordfor each one, all pointing to the load balancer's IP address. For example, tocreateA records forwww.example.com andexample.com, use the following:
NAME TYPE DATAwww A 30.90.80.100@ A 30.90.80.100
If you use Cloud DNS as your DNS provider, seeAdd, modify, and delete records.
Test the load balancer
Note: It might take a few minutes for the load balancer configuration topropagate globally after you first deploy it.Now that you have configured your load balancer, you can start sendingtraffic to the load balancer's IP address. If you configured a domain, you cansend traffic to the domain name as well. However, DNS propagation can take timeto complete, so you can start by using the IP address for testing.
Console
In the Google Cloud console, go to theLoad balancing page.
Click the load balancer that you just created.
Note the IP address of the load balancer.
Send traffic to the load balancer.
If you created anHTTP load balancer, you can test your load balancerby going to
http://IP_ADDRESS.ReplaceIP_ADDRESSwith theload balancer's IP address. Youshould be directed to the application you're running on the externalbackend.If you created anHTTPS load balancer, you can test your load balancerby going to
https://IP_ADDRESS.ReplaceIP_ADDRESSwith theload balancer's IP address. Youshould be directed to the you're application running on the externalbackend.
If that does not work and you are using a Google-managed certificate,confirm that your certificate resource's status is ACTIVE. For moreinformation, seeGoogle-managed SSL certificate resourcestatus.
Alternatively, you can use
curlfrom your local machine's command line.ReplaceIP_ADDRESSwith theload balancer's IPv4address. If you're using a Google-managed certificate, test the domain that points tothe load balancer's IP address. For example:curl -s 'https://www.example.com:443' --resolve www.example.com:443:IP_ADDRESS
Optional: If you are using a custom domain, you might need to wait for theupdated DNS settings to propagate. Then, test your domain in the web browser.
For help with troubleshooting, seeTroubleshooting external backend and internetNEG issues.
Additional configuration
This section expands on the configuration example to provide alternative andadditional configuration options. All of the tasks are optional. You can performthem in any order.
Enable Cloud CDN
When Cloud CDN is enabled, the external Application Load Balancer sends requests to theinternet NEG backend only when there is a Cloud CDN cache miss.
Console
In the Google Cloud console, go to theLoad balancing page.
Click the name of the load balancer that you want to modify.
ClickEdit.
ClickBackend configuration.
For the backend service with the internet NEG backend, clickEdit.
SelectEnable Cloud CDN.
Optional: Modify thecache mode andTTL settings.
ClickUpdate.
To review your changes, clickReview and finalize, and then clickUpdate.
gcloud
- To enable Cloud CDN on the backend service, use the followingcommand:
gcloud compute backend-services updateBACKEND_SERVICE \ --load-balancing-scheme=EXTERNAL_MANAGED \ --global \ --enable-cdn \ --cache-mode=CACHE_MODE
Set thecache mode by replacing
CACHE_MODEwith one of the following:CACHE_All_STATIC: automatically cachesstatic content.USE_ORIGIN_HEADERS(default): requires the origin to setvalid caching headers to cache content.FORCE_CACHE_ALL: caches all content, ignoring anyprivate,no-store, orno-cachedirectives inCache-Controlresponse headers.
Use a custom header to authenticate requests
To authenticate requests sent to your external backend, you can set a customheader to indicate that the request came from a Google Cloud loadbalancer. For example, you can configure the external backend to expect aparticular value for the HTTP request'sHost header, and you can configure thebackend service to set theHost header to that expected value.
Use the following steps to configure the backend service to add a customHostheader to each request.
Console
In the Google Cloud console, go to theLoad balancing page.
Click the name of the load balancer that you want to modify.
ClickEdit.
ClickBackend configuration.
For the backend service with the internet NEG backend, clickEdit.
ClickAdvanced configurations.
ForCustom request headers, clickAdd header:
- ForHeader name, enter
Host. - ForHeader value, enter
FQDN_NEG_ENDPOINT.
- ForHeader name, enter
ClickUpdate.
To review your changes, clickReview and finalize, and then clickUpdate.
gcloud
- Use the following command to configure the backend service to add a custom `Host` header to each request.
gcloud compute backend-services updateBACKEND_SERVICE \ --custom-request-header "Host:HEADER_VALUE" \ --load-balancing-scheme=EXTERNAL_MANAGED \ --global
Make sure that you also configured the external backend to expect aHostheader so that it can authenticate incoming requests.
For general information about custom request headers, seeConfigure customrequestheaders. Forother authentication methods, seeAuthenticate requests to the externalbackend.
Enable IAP on the external Application Load Balancer
Note: IAP isn't compatible with Cloud CDN.You can configure IAP to beenabled or disabled (default). If enabled, you must provide values foroauth2-client-id andoauth2-client-secret.
To enable IAP, update the backend serviceto include the--iap=enabled flag with theoauth2-client-id andoauth2-client-secret.
gcloud compute backend-services updateBACKEND_SERVICE_NAME \ --iap=enabled,oauth2-client-id=ID,oauth2-client-secret=SECRET \ --global
Optionally, you canenable IAPfor a Compute Engine resource by using the Google Cloud console,gcloud CLI, or API.
Update client HTTP keepalive timeout
The load balancer created in the previous steps has been configured witha default value for theclient HTTP keepalivetimeout.To update the client HTTP keepalive timeout, use the following instructions.
Console
In the Google Cloud console, go to theLoad balancing page.
- Click the name of the load balancer that you want to modify.
- ClickEdit.
- ClickFrontend configuration.
- ExpandAdvanced features. ForHTTP keepalive timeout, enter a timeout value.
- ClickUpdate.
- To review your changes, clickReview and finalize, and then clickUpdate.
gcloud
For an HTTP load balancer, update the target HTTP proxy by using thegcloud compute target-http-proxies update command:
gcloud compute target-http-proxies updateTARGET_HTTP_PROXY_NAME \ --http-keep-alive-timeout-sec=HTTP_KEEP_ALIVE_TIMEOUT_SEC \ --global
For an HTTPS load balancer, update the target HTTPS proxy by using thegcloud compute target-https-proxies update command:
gcloud compute target-https-proxies updateTARGET_HTTPS_PROXY_NAME \ --http-keep-alive-timeout-sec=HTTP_KEEP_ALIVE_TIMEOUT_SEC \ --global
Replace the following:
TARGET_HTTP_PROXY_NAME: the name of the target HTTP proxy.TARGET_HTTPS_PROXY_NAME: the name of the target HTTPS proxy.HTTP_KEEP_ALIVE_TIMEOUT_SEC: the HTTP keepalive timeout value from 5 to 600 seconds.
What's next
- To check whether Cloud CDN is serving responses from cache, seeViewing logs.
- To learn about which content is cacheable or non-cacheable, seeCaching overview.
- To find Cloud CDN's points of presence, seeCachelocations.
- Clean up the load balancer setup.
- To learn how to disable Cloud CDN, seeDisableCloud CDN.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-15 UTC.