Configure an edge extension Stay organized with collections Save and categorize content based on your preferences.
Service Extensions enablessupported Application Load Balancersto use plugins to insert custom processingin the processing path.Edge extensions runin the request processing path when the load balancer receives request headersand before it evaluates theURL map orcalls Cloud CDN, which lets you influence caching and routing.This page describes how to configure edge extensions.
For an overview about Application Load Balancer extensions, seeCloud Load Balancing extensions overview.
An extension for an Application Load Balancer points to the following resources:
- A forwarding rule to attach to
- A plugin
The extension references the load balancerforwarding rule to attach to.After you configure the resource, the load balancer starts sendingmatching requests to extension services. You can attach only one edge extensionto a forwarding rule and include only one plugin in an edge extension chain.
For information about the limits related to Application Load Balancer extensions,see theQuotas and limits page.
Configure using plugins
This section uses an example to show you how to configure an edge extension byusing a plugin that rewrites the:host request header toservice-extensions.com when the path matches/extensions. The earlier hostand the newly configured host are mapped to backend services in differentregions, which demonstrates the routing behavior.
All extension resources that reference a given plugin must be of the same type.The extensions must also have the same load balancing scheme. You can'tconfigure Cloud Load Balancing extensions with plugins that are alreadyused in Media CDN extensions.
Before you begin
Create a plugin that contains yourcustom code.
Create and configure anApplication Load Balancer that supports edge extension plugins.
Follow the instructions on theSet up a global external Application Load Balancer with VM instance group backends page for all steps, except the following:
- Name the backend service as
service-one. - Point
service-oneto a virtual machine (VM) instance in regionA. - Point
gl7-gxlb-url-maptoservice-oneby default.
- Name the backend service as
Set up an additional backend service,
service-twoand point it toa VM in regionB.To the URL map, add a path matcher pointing to
service-two. Use thegcloud compute url-maps add-path-matchercommandwith the following sample values:gcloud compute url-maps add-path-matcher gl7-gxlb-url-map \ --path-matcher-name=rewrite-host \ --default-service=service-two \ --new-hosts=service-extensions.com \ --location=global
Set up a way to send test requests to your service (for example, by runningcurl).
Configure an edge extension by using a plugin
Check the behavior before an extension is configured.
Verify that a request without an explicit path goes to region
A:curlFORWARDING_RULE_IP
Replace
FORWARDING_RULE_IPwith the IP addressof the forwarding rule. To find the IP address, use thegcloud compute forwarding-rules describecommand.The output is similar to the following and indicates that the page isserved from a VM in
region A:Page served from region-A-vmVerify that there is no match for
/extensionsin the URL map:curlFORWARDING_RULE_IP/extensions
Replace
FORWARDING_RULE_IPwith the IP addressof the forwarding rule. To find the IP address, use thegcloud compute forwarding-rules describecommand.The output indicates that there is no match for
/extensionsin the URLmap. The output is similar to the following:<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><html><head><title>404 Not Found</title></head><body>...
Configure the edge extension.
Console
In the Google Cloud console, go to theService Extensions page.
ClickCreate extension.
A wizard opens to guide you through some initial steps.
For the product, selectLoad Balancing. Then, clickContinue.
A list ofsupported Application Load Balancersappears.
For the load balancer type, select global external Application Load Balancer.Then, clickContinue.
For the extension type, selectEdge extensions, and then clickContinue.
To open theCreate extension form, clickContinue.
In theCreate extension form, notice that thepreceding selections aren't editable.
In theBasics section, do the following:
Specify a unique name for the extension.
The name must start with a lowercase letter followed by up to 62lowercase letters, numbers, or hyphens and must not end with ahyphen.
Optional: Enter a brief description about the extension by usinga maximum of 1,024 characters.
Optional: In theLabels section, clickAdd label. Then, inthe row that appears, do the following:
- ForKey, enter a key name.
- ForValue, enter a value for the key.
To add more key-value pairs, clickAdd label. You can add amaximum of 64 key-value pairs.
For more information about labels, seeCreate and update labels for projects.
ForForwarding rules, select one or more forwarding rules toassociate with the extension—for example,
cr-xlb-forwarding-rule.Forwarding rules that are already associated with another extensioncan't be selected and appear disabled.
ForExtension chains, add one or more extension chains toexecute for a matching request.
To add an extension chain, do the following, and then clickDone:
ForNew extension chain, specify a unique name.
The name must conform withRFC-1034,use only lowercase letters, numbers, and hyphens, and have amaximum length of 63 characters. Additionally, the first charactermust be a letter and the last character must be a letter or a number.
To match requests for which the extension chain is executed, forMatch condition, specify a Common Expression Language (CEL)expression—for example,
request.path.startsWith("/extensions").Edge extensions let you use only one regular expression perCEL expression.
For more information about CEL expressions, clickGet syntax help or seeCEL matcher language reference.
Add an extension to execute for a matching request. For edgeextensions, you can specify only one extension.
Important: You can include only one plugin in an edge extension chain.UnderExtensions, do the following, and then clickDone:
ForProgrammability type, selectPlugins.
ForExtension name, specify a unique name.
The name must conform with RFC-1034, use only lowercaseletters, numbers, and hyphens, and have a maximum length of63 characters. Additionally, the first character must be aletter and the last a letter or a number.
ForPlugin, select a plugincreated using Service Extensionsfor the same product and extension type.
ForForward headers, clickAdd header, and then addHTTP headers to forward to the extension (from the client orthe backend). If a header isn't specified, all headers aresent.
Optional: ForFail open, if you want the extensionto fail open, selectEnabled. In this case, if the call tothe extension fails or times out, request or responseprocessing continues without error. Any subsequent extensionsin the extension chain are also executed.
By default, theFail open field isn't selected. In thiscase, if response headers have not been delivered to thedownstream client, a generic HTTP
500status code isreturned to the client. If response headers have beendelivered, the HTTP stream to the downstream client is reset.
ClickCreate extension.
gcloud
Define the plugin in a YAML file and associate it with a globalforwarding rule—for example,
cr-xlb-forwarding-rule.cat >edge-plugin.yaml <<EOF name: edge-ext forwardingRules: - https://www.googleapis.com/compute/v1/projects/PROJECT_ID/regions/global/forwardingRules/cr-xlb-forwarding-rule loadBalancingScheme: EXTERNAL_MANAGED extensionChains: - name: "chain1" matchCondition: celExpression: 'request.path.startsWith("/extensions")' extensions: - name: 'ext1' service: projects/PROJECT_ID/locations/global/wasmPlugins/WASM_PLUGIN failOpen: false supportedEvents: - REQUEST_HEADERSEOFReplace the following:
PROJECT_ID: theproject IDWASM_PLUGIN: the ID or the fullyqualified name of the plugin
Edge extensions let you use only one regular expression perCEL expression.
Import the edge extension. Use the
gcloud service-extensions lb-edge-extensions importcommand with the following sample values:gcloud service-extensions lb-edge-extensions import edge-ext \ --source=edge-plugin.yaml \ --location=global
After an edge extension is created, it takes a little time for the new pluginto be distributed across all locations. The time might vary acrosslocations because the plugin isn't delivered to all locations simultaneously.
To verify that the edge extension works as expected, use the same
curlcommand:curlFORWARDING_RULE_IP/extensions
The output is similar to the following and indicates that the page isserved from a VM in
region B:Page served from region-B-vmTo verify that the plugin runs only for requests with the
/extensionpath prefix, repeat thecurlcommand without a path.curlFORWARDING_RULE_IP
The output is similar to the following:
Page served from region-A-vm
Limitations for edge extensions
- You can attach only one edge extension to a forwarding rule.
- Edge extensions don't support HTTP body processing.
- Edge extensions let you use only one regular expression per CEL expression.
For limitations that are applicable to all extensions, seeLimitations for extensions.
What's next
- View Rust, Go, and C++ plugin examples and testing tools in theService Extensions GitHub repository for plugins.
- Manage extensions
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-17 UTC.