REGION_ID is a code that Google assigns based on
the region you select when you create your app. Including
REGION_ID.r in App Engine URLs is optional for
existing apps and will soon be required for all new apps.
Learn more about region IDs.
dispatch.yaml allows you to override routing
You can use the
dispatch.yaml to send incoming requests to a specific service
(formerly known as modules) based on the path or hostname in the URL.
For more information, see How Requests are Routed.
Deploying the dispatch file
dispatch.yaml file can reside anywhere in your source code directory.
To deploy the dispatch configuration file without otherwise altering the currently serving version, use one of the following commands in the directory containing your dispatch file, depending on your environment:
gcloud app deploy dispatch.yaml
mvn appengine:deployDispatch dispatch.yaml
gradle appengineDeployDispatch dispatch.yaml
For more information about the deployment commands, see Deploying a Java 8 App.
SyntaxThe root element in the
dispatch:and contains a list of routing definitions that are specified by the following subelements.
The rules that you define in your dispatch file must use HTTP URL patterns
that include the "
." notation for separating subdomains. URLs
defined with the HTTPS "
-dot-" notation are not supported.
Dispatch rules are order dependent, and can also apply to the URLs that you define in your cron file.
Specifies the name of the service that will handle the requests that
Tip: You can include glob patterns like the
A URL pattern that can include the hostname and URL path. Glob characters can be used to match patterns. The Glob characters can be specified only at the beginning of the pattern and end of the pattern. Specify the URL pattern within quotes.
URL paths that begin with
The following is a sample dispatch file that routes requests to
https://simple-sample.uc.r.appspot.com and requests like
https://simple-sample.uc.r.appspot.com/favicon.ico to the
default service. All
static content is served from the
default service. Mobile requests like
https://simple-sample.uc.r.appspot.com/mobile/ are routed to a mobile frontend, and
worker requests like
https://simple-sample.uc.r.appspot.com/work/ are routed to a
dispatch: # Default service serves the typical web resources and all static resources. - url: "*/favicon.ico" service: default # Default service serves simple hostname request. - url: "simple-sample.uc.r.appspot.com/" service: default # Send all mobile traffic to the mobile frontend. - url: "*/mobile/*" service: mobile-frontend # Send all work to the one static backend. - url: "*/work/*" service: static-backend
If you prefer general routing rules that match many possible requests, you can define rules with wider scopes. For example:
# Send any path that begins with “simple-sample.uc.r.appspot.com/mobile” to the mobile-frontend service. - url: "simple-sample.uc.r.appspot.com/mobile*" service: mobile-frontend # Send any domain/sub-domain with a path that starts with “work” to the static backend service. - url: "*/work*" service: static-backend
You can also write expressions that are more strict:
# Matches the path "/fun", but not "/fun2" or "/fun/other" - url: "*/fun" service: mobile-frontend # Matches the hostname 'customer1.myapp.com', but not '1.customer1.myapp.com. - url: "customer1.myapp.com/*" service: static-backend
The dispatch file can contain up to 20 routing rules. When specifying the URL string, neither the hostname nor the path can be longer than 100 characters.
Deleting all dispatch rules
To delete all dispatch rules:
Edit the contents of the
dispatch.yamlfile to App Engine.