cheeze
cheeze

Reputation: 587

How to map only subdomain to App Engine without the naked domain?

My use case is this: I have a domain that points to a server at IP 1.2.3.4 and I would like a subdomain at the domain to point to my App Engine application i.e.

example.com --> 1.2.3.4

app.example.com --> App Engine application

The naked domain as well as the www subdomain must point to the standalone server.

From what I've found out so far, this doesn't seem possible.

Would anyone be able to confirm if this configuration is indeed not possible?

Upvotes: 6

Views: 2160

Answers (7)

kblst
kblst

Reputation: 519

App Engine doesn't need to have the A records on the root domain if you are only serving from a subdomain. App Engine should work properly for you with just the one CNAME on subdomain.example.com.

Duplicate of App Engine and Firebase Hosting in One Domain

This is the correct answer and is working as expected.

Upvotes: 0

N. Varas
N. Varas

Reputation: 21

This is definitely possible, I've done it for the exact same scenario:

  1. In App engine, when you verify your domain, only map the subdomain (mysubdomain.example.com). GCP will prepopulate the naked and www domains. Remove them before proceeding.GCP will then provide the A, AAAA, and CNAME records for you to add to your DNS records.
  2. Go to wherever you manage those (Google Domains, GoDaddy, etc), and add all four A's, all four AAAA's and the CNAME yo your subdomain/host

Eventually, gcp should see it's provided records on the DNS records and should issue certificates for https.

On gcp, adjust the dispatch.yaml file to route things to the service I wanted:

dispatch:
  - url: "mysubdomain.example.com/*"
    service: myservice

Your service should now be accessible via https://mysubdomain.example.com with a pretty padlock to go with it.

Upvotes: 2

mehmet.ali.anil
mehmet.ali.anil

Reputation: 525

I might actually have a better solution to this. You can only verify the subdomain.domain.tld with google. Then you only will add A and AAAA entries to the DNS, with the alias subdomain.

subdomaid.domain.tld will then be independent from domain.tld

Upvotes: 5

atlanteh
atlanteh

Reputation: 5835

There might be another option, but I can't really test it for sure as I can't risk it my app ever fails without me knowing.
So from my empirical testing, I was able to set the domain to external hosting and subdomain to GAE:

  1. point main domain to google.
  2. point subdomain to google
  3. wait for certificates to be issued
  4. remove domain from "custom domains" tab (click on the trash can)
  5. point your domain wherever you want
  6. This worked for me for 4 days, in test env, but I couldn't really risk my app of this kind of failure, so I just used the accepted answer at the end (redirect domain to www)

Upvotes: 1

Riël
Riël

Reputation: 1321

I found out it is possible to verify ownership of the whole url, and use that...

Upvotes: 0

cheeze
cheeze

Reputation: 587

After much testing, I've come to the conclusion that the scenario which I've painted is not feasible. So I settled for www.example.com to point to the web server (1.2.3.4) and app.example.com

When users go to the naked domain example.com, they get redirected to www.example.com

Here's what I did:

  • Remap the naked domain's A records (4 of them, and 4 AAAA records) back to the IP addresses that App Engine suggested.
  • Added a redirect of the naked domain to the www subdomain, and
  • Added an A record for www to point to the web server IP (i.e. 1.2.3.4)
  • Finally, added a CNAME record for app to point to ghs.googlehosted.com so that app.example.com points to the App Engine application.

Upvotes: 1

alpeware
alpeware

Reputation: 482

Yes, I can confirm this is possible. In fact, it is the recommended way for handling the microservice architecture on App Engine [0].

In your case specifically, all you have to do is create a CNAME with your DNS registrar pointing to ghs.googlehosted.com.

You then have to first verify your TLD with App Engine and add a specific mapping to your subdomain as described here [1].

Let me know if you have any specific questions with the process.

[0] https://cloud.google.com/appengine/docs/standard/python/microservices-on-app-engine

[1] https://cloud.google.com/appengine/docs/standard/python/console/using-custom-domains-and-ssl

Upvotes: 1

Related Questions