Google App Engine module and custom domain - google-app-engine

I'm trying to assign custom domain to App Engine module. At the moment I have staging.example.com pointed to app-id.appspot.com and that works correctly but I also want to assign api.staging.example.com to api.app-id.appspot.com. I've created CNAME record from api.staging.example.com to ghs.googlehosted.com, added api.staging.domain.com in developers console/appengine/settings/custom domains and here is my dispatch.yaml:
dispatch:
- url: "staging.example.com/*"
module: default
- url: "api.staging.example.com/*"
module: api
Any ideas what could be wrong? Every request to endpoints on api.staging.example.com shows only 404 error and I can't see this in the logs, it looks like api.staging.example.com is pointed to somewhere else, all request to api-app-id.appspot.com works correctly.

Are you making HTTPS requests? The official docs note that double-wildcard domains are not supported for SSL certificates.
Google recommends using the HTTPS protocol to send requests to your app. Google does not issue SSL certificates for double-wildcard domains hosted at appspot.com. Therefore with HTTPS you must use the string "-dot-" instead of "." to separate subdomains
So you'll need to replace the first . with -dot- to follow this pattern:
https://module-dot-app-id.appspot.com. In your case api-dot-app-id.appspot.com.

OK, I know where is my problem - Google Cloud Endpoints.
Google Cloud Endpoints does not support custom domains.
https://cloud.google.com/appengine/docs/python/endpoints/
https://code.google.com/p/googleappengine/issues/detail?id=9384

Related

Google App Engine custom domain not redirecting to https

I deployed a Streamlit app to App Engine and configured a custom domain https://datanerd.tech that I purchased through Google Domains.
The problem I'm running into is that when I type in the browser the naked domain datanerd.tech, I am not getting auto re-directed to a secure connection via https://datanerd.tech. Instead, it stays with http://datanerd.tech even though a secure option is available.
This is my app.yaml file:
runtime: custom
env: flex
service: default
I'm unable to use the following in the yaml file to force a secure connection because I need a flexible environment.
handlers:
- url: /.*
secure: always
redirect_http_response_code: 301
script: auto
I'm not as experienced with setting up web servers, and so I'm not sure if this is a Google issue or a Streamlit issue.
EDIT
Here are the rules I have set up for connecting my google domain to App Engine:
App Engine configuration
Google Domain configuration
EDIT 2:
I attempted domain forwarding from my Google Domain account using https://datanerd.tech and the url no longer worked due to "To many redirects". I even tried cycling the different options of 'Redirect Type', 'Path Forwarding', and 'SSL' with no luck.
I was NOT able to solve this issue using App Engine. I was able to get a partial solution for www.datanerd.tech using #NoCommandLine's solution.
Instead, Since I wasn't dependent on App Engine; I switched services to Cloud Run and was able to map the custom domain with no issues.
Thanks again for your patience #NoCommandLine.
Login to Google Domains and select your domain
Click on 'DNS' on the (left hand side) of the page and on the right hand side of the page, look for the Domain Forward section
Add an entry to forward http://datanerd.tech to https://datanerd.tech
Update
This is what shows up for https://datanerd.tech. http://datanerd.tech also works

App Engine with subdomains displaying IPs rather than content

I have configured the App Engine to use a custom domain that I have on CloudFlare. I added the TXT record for verification and all the A and AAAA entries with the given IP addresses.
I have also added 2 CNAME entries that matches the name of 2 services that I have deployed (web and api). I have done this on App Engine settings and in the CloudFlare dashboard.
When I try to go to web.mydomain.com or api.mydomain.com on both cases rather than seeing the content I receive a text response showing a list of IP addresses, and the content served by the Google Frontend (according to the response headers).
Is there any additional configuration I need to do for this to work?
Both services works fine if I access them using the default domain provided by Google (appspot.com)
Thanks!
It turned out that I had to deploy the dispatch.yml file in order for this to work
dispatch:
- url: "api.mydomain.com/*"
service: api
- url: "web.mydomain.com/*"
service: web

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.

Custom Domain for App Engine App Wrongly Pointing to SSL

I have an App Engine App at http://1.lyfekit.appspot.com/ and I want to use the custom domain http:// www. lyfekit .com/
I verified the domain and added it to app engine app settings. I added the CNAME record www pointing to ghs.googlehosted .com
BUT, http:// www. lyfekit .com/ is going to https: //lyfekit .com/ and is giving me an SSL error. I do not need https. I simply want http.
The way I understand, if I am not using https, I do not need to configure a Google Apps Account for the domain.
HTTPS is a protocol. It's totally separate from a domain name.
Somewhere in your app.yaml or web.xml file you have specified that you want a connection to be secure. App Engine follows your instructions and tries to use HTTPS protocol instead of HTTP protocol. Remove these instructions, and App Engine will stop using HTTPS
I'm not sure what you have done but the default module for your app (the one which your domain is mapped to) can be seen here:
http://lyfekit.appspot.com
and as you can see it redirects to https (because it will have secured:always set in the app.yaml file).
With your original URL you are specifying a particular version of your app (version 1) but as you can see by accessing the main appspot domain that version is not set as the default version.

Multiple custom domains to specific version of Google App Engine app

Let's say I have myapp.appspot.com and two custom domains respectively called foo.com and bar.com. How do I configure Google App Engine (GAE) such that:
(www.)foo.com -> foo.myapp.appspot.com
(www.)bar.com -> bar.myapp.appspot.com
(www.)foo.com -> myapp.appspot.com (default version)
I'm reading https://developers.google.com/appengine/docs/domain but I still don't understand how to configure it. I get the impression that GAE only supports wildcard for one custom domain e.g. **.foo.com.
You can't really do that directly, as you associate your custom domain with an App ID rather than the App URL.
I guess you could map both foo.com and bar.com to your App ID, then in the default version of your App Engine parse the URL, and redirect accordingly, but it's not a great solution as you would be redirecting from your custom domain back to appspot.com domain.
You can route using the dispatch file (dispatch.yaml).
This blog post gave me the necessary info, and I imagine for the case of needing to map multiple domains to different modules would require a dispatch.yaml something like this:
# Dispatch
# ========
---
dispatch:
- url: 'foo.com/*'
module: foo
- url: 'bar.com/*'
module: bar
Don't forget to add the custom domains as well as SSL certs in the App Engine console.

Resources