App Engine custom domain with service - google-app-engine

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?

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 own example.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 click Save mappings
Click Done (you already did this last step)
Update App Engine dispatch rules
Run gcloud app describe --project <GOOGLE_CLOUD_PROJECT_ID> and take a look at the current section of dispatchRules
Create dispatch.yaml or dispatch.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>

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.

Related

How to configure custom domain for App Engine for service that is not the defautl in GCP?

I have one Node aplication runing on default App Engine service. Its was runing on "urlFromWebSite.appspot.com", and I config it to run in my domain url "customUrl.ai".
I built a second service with Node with name "second-service",and its runing at
"service-two-doturlFromWebSite.appspot.com", but i want to run at "subDomain.customUrl.ai"
I tried dispatch.yaml file with the url that i want for 'second-service';
Stack post 1 talking about dipatch
Stack post 1 talking about dipatch
GCP explanation for dispatch
I have tried Custom domains in App Engine > Settings > Custom domains;
GCP documentation for mapping custom domains
At custom domains I config my subdomain url, and it generates the DNS. ยด
I have question here:
Where should I add this DNS config? At the "customUrl" or should i create a new record set for it?
I have been strugling with it for 2 days already, and could figure it out how to solve it. How should i config this to change my second service's url for a custom subdomain?
When user enters customUrl.ai in a browser, traffic should be routed to Google's servers (for your GAE project). To do that, you configure DNS settings on your domain registrar's end.
When user enters subDomain.customUrl.ai in a browser, traffic should be routed to Google's servers. To do that, you also configure DNS settings on your domain registrar's end.
Both #1 & #2 are done for the same domain on your domain registrar's end (which is GoDaddy in your case). I believe this is what #JohnHanley is referring to. Put another way - just go to GoDaddy, find your domain and create entries corresponding to what GAE has outlined for you. If they are duplicates, GoDaddy will tell you.

Setting target url with gcloud

I have been using the Google App Engine Launcher's "Deploy" button. I realize that the Launcher is going away at the end of July 2020, so I'm trying to learn to use gcloud. My web site has a custom url, www.xxx.org, but "gcloud app deploy" uploads to xxx.appspot.com instead of to www.xxx.org, presumably because "target url" is set to xxx.appspot.com. Can someone please tell me what gcloud command I need to use to change "target url" to www.xxx.org, or some other scheme that would work? I've wandered through lots of gcloud and GAE documentation and web searches without being able to figure out what I need to do.
There is a very good and complete guide about mapping a custom domain to your application in the official documentation. As #DanCornilescu said,it needs to be configured, but it is not necessary to be done before deployment.
Basically, you need to follow the steps from the guide:
1) Verify that you are the owner of your domain through Webmaster
Central
2)Ensure that your domain has been verified, otherwise you will not be able to proceed with the following steps. Note that only verified domains will be displayed.
3)If you need to delegate the ownership of your domain to other users or service accounts, you can add permission through the Webmaster Central page
4)After you verify ownership of your domain, you can map that domain to your App Engine app
5)Add the resource records that you receive to the DNS configuration of your domain registrar
6)Test for success by browsing to your app via its new domain URL, for example www.example.com
In case you need to do more complex mappings for different urls and subdomains you can always write down the routing rules in the dispatch.yaml file and they will be mapped successfully.
Also, to add a bit more of information about the dipatch.yaml file, it will handle the routing in the App as opposed with the app.yaml which will take care of the App's settings. Both .yamls can exist in the same application and can be deployed at the same time by using the following gcloud command:
gcloud app deploy app.yaml dispatch.yaml
The deployment is always done to .appspot.com, the custom domain is automatically updated if it is already configured. If it is not then it needs to be configured (it can be done after the deployment as well).

Subdomain to resolve to a different website via DNS

I have two websites: (A) one is a static website hosted on github while the other (B) is an admin page hosted on Google Cloud (app engine). Currently, the DNS is set up so that the root of the site resolves to A. I would like to set up a sub-domain such as admin.root.com/ to resolve instead to B. I don't want to simply redirect the user as I would like the URL to be the one of the site.
Is there a way to achieve this via DNS? Note: I am using CloudFlare for the DNS settings.
Sure you can, all you need is just to set up a CNAME record for that on the DNS which manages root.com.
Supposing you want admin.root.com to point to somepage.github.com, the CNAME record shall consist of the following key/value pair:
key: admin
value: somepage.github.com.
If you want to redirect the user depending on the URL, you should configure and deploy the dispatch.yaml in your Google Cloud App Engine application. Find below the information depending on the environment that you are using:
AE Standard environment
AE Flexible environment
To use this solution, you should first resolve to B.

Google App Engine Wildcard Subdomains

I have Node JS app running on google app engine.
I have linked a custom domain to it: www.singlelisting.co
BUT
I need wildcard subdomains to also link to the node application
For Example: 6.singlelisting.co or ns324.singlelisting.co
I have not had much luck reading the documentation on google developers site
I am using cloudflare for DNS management and have added * records for all the google A and AAAA records. I believe the problem is have google is seeing the subdomains. Any help would be greatly appreciated
You have two options:
Mapping subdomains: in your App Engine Custom domains config you need to add the following entry *.singlelisting.co and then update the DSN management with the required records (as you probably did). This means that requests through 6.singlelisting.co or ns324.singlelisting.co will be handled by the 6, respectively ns324 service of you App Engine deployment, if available. As the documentation states:
If you set up a wildcard subdomain mapping for your custom domain, then your application serves requests for any subdomain that matches:
.If the user browses a domain that matches a service name, the application serves that service.
By using a dispatch file (more info here): this file will override the routing rules established (or not) through your domains config.
So basically if you do not have services named 6 and ns324 that will automatically handle requests incoming through the wildcard rule *.singlelisting.co, you have to describe the routing using the dispatch.yaml.

How to use Google App Engine with my own naked domain (not subdomain)?

After hours of reading about and experimenting with DNS records I can access my Google App Engine app via these URLs:
myappid.appspot.com
www.myappid.myowndomain.example
What does not work:
myowndomain.example
www.myowndomain.example
I want to be able to serve my app directly off my domain and not a subdomain. I've seen apps that do this. Is there any way to do this without a URL redirect?
[Update April 2016] This answer is now outdated, custom naked domain mapping is supported, see Lawrence Mok's answer.
I have figured it out!
First off: it is impossible to link something like mydomain.example with your appspot app. This is considered a naked domain, which is not supported by Google App Engine (anymore). Strictly speaking, the answer to my question has to be "impossible". Read on...
All you can do is add subdomains pointing to your app, e.g myappid.mydomain.example. The key to get your top level domain linked to your app is to realize that www is a subdomain like any other!
myappid.mydomain.example is treated exactly the same as www.mydomain.example!
Here are the steps:
Go to appengine.google.com, open your app
Administration > Versions > Add Domain... (your domain has to be linked to your Google Apps account, follow the steps to do that including the domain verification.)
Go to www.google.com/a/yourdomain.example
Dashboard > your app should be listed here. Click on it.
myappid settings page > Web address > Add new URL
Simply enter www and click Add
Using your domain hosting provider's web interface, add a CNAME for www for your domain and point to ghs.googlehosted.com
Now you have www.mydomain.example linked to your app.
I wished this would have been more obvious in the documentation.
[update 2015-09-28] Now Google lets you add custom domains (including naked domains) and setup SSL without the need of Google Apps. For details refer to here: https://cloud.google.com/appengine/docs/using-custom-domains-and-ssl?hl=en
I just discovered today (as of 2014-04-11) a new custom domain settings page is available from Google Developers Console:
1. Go to https://console.developers.google.com/project
2. Click on your project
3. On the left click "App Engine"
4. Click "Settings"
There you go! You can configure custom domain without the need of Google App account!
[Update April 2016] This answer is now outdated, custom naked domain mapping is supported, see Lawrence Mok's answer.
See http://www.google.com/support/a/bin/answer.py?hl=en&answer=91077 for the details. Once you have signed up for Google Apps for Your Domain:
# Sign in to the Google App Engine admin console.
# Go to Administration > Versions
# Click the 'Add Domain...' button under Domain Setup.
# Enter your domain name in the 'Domain Name:' field
# Click 'Add Domain'. You will be directed to the Google Apps administrator console to complete the process.
# Log in to the Google Apps control panel with your administrator account.
# Accept the terms and specify the access URL you'd like to provide for your application.
# Click 'Accept
You can't use a naked domain, though, such as whatever.example (but www.whatever.example does work), because:
Due to recent changes, Google App Engine no longer supports mapping
your app to a naked domain. If your domain registrar supports URL
redirects, you can redirect from http://yourdomain.example to your app,
which can be served from domains like http://www.yourdomain.example or
http://appid.yourdomain.example.
as specified at http://www.google.com/support/a/bin/answer.py?answer=91080
If like me you have seen this message while trying to add 'www' as a subdomain inorder to get your own domain working:
'Already used, please remove previous
mapping first . '
The above process mentioned in other answers has changed slightly if you are using Google Apps for your domain.
You must now do this as well:
Google Apps -> Service Settings -> Sites. Click 'Web address mapping' and remove the 'www' mapping which has been added by default to Sites.
Then you can add the 'www' subdomain for your App engine app
see this link:
http://groups.google.com/group/google-appengine/web/deleting-existing-www-mapping-from-google-apps
Another solution which is given by Google is URL forwarding: http://www.google.com/support/a/bin/answer.py?hl=en-in&answer=61057
Google does offer naked domain redirection.
Login to your google apps account and select "manage this domain"
Navigate to Domain settings
Within Domain Setings, navigate to Domain names
There's a link that says "change the A record". Clicking that will give you the destination IPs for the A records you need to create.
Google does not provide an IP for us to set A record. If it would we could use naked domains.
There is another option, by setting A record to foreign web server's IP and that server could make an HTTP redirect from e.g domain.example to www.domain.example (check out GiDNS)
For App Engine in 2019, googles has made it easier to set up a custom domain.
Google App Engine -> Settings -> Custom Domains
Verify your domain
Select Your Domain Name Registra
Reminder: Use TXT Record with the value Google provides without a existing CNAME record, otherwise TXT Record will be override
Follow the steps on the page, which includes the configuration of your subdomain, CNAME Record, A Record, AAAA Record, and you'll be good to go.
Just managed to sort this finally after hours. The www subdomain was pointing to Sites, but the front end wasn't showing me that.
After taking the plunge and setting the CNAME to gwh.google.com, and enabling / disabling Sites a couple of times (see the comment from Rodrigo Moraes on http://groups.google.com/group/google-appengine/web/deleting-existing-www-mapping-from-google-apps) I was able to set the Sites address to use the www subdomain.
I was then able to change it away from using the www subdomain, at which point the appengine app allowed me to specify the www subdomain.
That is one dirty fix - basically turning on and off Sites until it works!
When you go to "Application Settings -> Add Domain" It will ask to select login account, probably you are already on gmail account so it will show gmail account as well, but you should use Google Apps account where you have mapped your custom domain.
You can redirect forward or mask your domain name in godaddy but I don't know about other hosting sites.Have a look on this link
Here is a tutorial from Google about mapping your App on custom domain: https://cloud.google.com/appengine/docs/domain?hl=FR
It should be the latest update. But please note these 2 things:
1- You may not find you App in the new developer console, then the only workaround for that is download your source code, create a new app from the new developer console and deploy it.
2- You find your App on the developer console, but under the Compute menu you may not find the App Engine Settings as mentioned in the tutorial, then you have to proceed the same as i explained in the first point (create another application)
I hope this helps !
You can create a custom domain (including naked domain) for your App Engine and you can also set up self managed SSL certificates there.
To use a custom domain, map the domain to your app, then update your DNS records. You can map a naked domain, such as example.com or a subdomain, such as subdomain.example.com. You can also use wildcards to map subdomains.
The steps to map custom domain to your application are following -
In Console,go to the Application settings tab of the App Engine Settings page
-->If you need to enable G Suite authentication then click Edit to modify the Google Accounts API Referrer-->In the Google Authentication drop-down menu, select G Suite domain, then add your domain such as example.com in the empty field.
Go to the Custom Domains tab of the App Engine Settings page--> Click on add custom Domain-->If your Domain is already verified then select it from the drop down menu-->click Continue.
If you haven't verified your domain yet, follow the steps below:
a) Select Verify a new domain from the drop-down menu.
b) Enter your naked domain name (such as "example.com") and click Verify.
c) Enter information in the Webmaster Central window that appears.
d) After you complete the steps in Webmaster Central, return to the Add a new
custom domain page in the Google Cloud Console.
In the Point your domain to (project-ID) section, specify the domain and subdomains that you want to map.We recommend mapping the naked domain and the www subdomain-->click Save mapping.
Sign in to your domain registrar web site and update your DNS records.
Please refer to the following link for detailed description of required steps -
https://cloud.google.com/appengine/docs/standard/python/mapping-custom-domains
You must try like this, Application Settings > Add Domain...

Resources