App Engine custom domain with service
Solution 1
Check how to use subdomains and how wildcard mapping works in the GCP docs here (actually these are the next steps at the website which you've followed and linked). Make sure that your DNS provider permits wildcards in CNAME
host entries, otherwise such mapping will not be possible.
This blog post shows a real-life example of matching subdomains to services with App Engine.
Solution 2
Here's a step-by-step:
- Ensure you are a owner of the parent domain in here: https://www.google.com/webmasters/verification/home (e.g for
subdomain.example.com
you need to ownexample.com
) If not, ask a friend to add you as an owner. - Create a CNAME record pointing to:
ghs.googlehosted.com
(in Cloud DNS or wherever). Note: This will cause downtime, but it is required for App Engine to create an SSL certificate so downtime is unavoidable... - Add custom domain to App Engine
- Go to
App Engine -> Settings -> Custom Domains
- Click on
Add a custom domain
- Choose the verified parent domain and click
Continue
- Enter the subdomain (e.g
subdomain.example.com
) and clickSave mappings
- Click
Done
(you already did this last step)
- Go to
- Update App Engine dispatch rules
- Run
gcloud app describe --project <GOOGLE_CLOUD_PROJECT_ID>
and take a look at the current section ofdispatchRules
- Create
dispatch.yaml
ordispatch.yml
file with your new rule as well as the ones already existing above (note the file format is different from the command output)
dispatch: - url: <DOMAIN>/* # e.g. subdomain.example.com/* service: <SERVICE-NAME>
- Deploy it using:
gcloud app deploy dispatch.yaml --project <GOOGLE_CLOUD_PROJECT_ID>
- Run
Related videos on Youtube
sanooj
Updated on June 04, 2022Comments
-
sanooj almost 2 years
I set up a custom domain with App Engine after following the instructions on DNS records:
https://cloud.google.com/appengine/docs/standard/java/mapping-custom-domains
It's working for the default service using URL http://MY_CUSTOM_DOMAIN but I'm unable to access other services with URLs http://SERVICE_ID.MY_CUSTOM_DOMAIN. Do I need to map a different set of DNS records?
-
Oded Niv over 4 years@henry-woody both
dispatch.yaml
anddispatch.yml
work -
howMuchCheeseIsTooMuchCheese over 4 yearsKey take away, if your service is named "api" and you create a custom domain for "api.expample.com", App Engine will automatically match it.
-
Oliver Dixon over 3 yearsIs it possible to do sub-domain only? Which is a very common use case?