Using Custom Domains with App Engine

I explore using custom domains with App Engine.

App Engine aplication Creating Google App Engine Project has google asigned appspot.com subdomain. For example https://argon-retina-346404.uc.r.appspot.com.

I want to assign the custom domain testapp.raibis.lt for this application.

Visit App Engine > Settings > Custom Domains > Add Custom Domain.

/posts/gcp/using_custom_domains_with_app_engine/001_custom_domain.png

Click Add Custom Domain

/posts/gcp/using_custom_domains_with_app_engine/002_custom_domain.png

Clicking Verify will redirect to Google Webmaster Central. Here have to select the Other option.

/posts/gcp/using_custom_domains_with_app_engine/003_custom_domain.png

I have to visit Cloudflare and add two DNS records: CNAME testapp for subdomaintestapp.raibis.lt and TXT record for site verification.

/posts/gcp/using_custom_domains_with_app_engine/004_custom_domain.png

/posts/gcp/using_custom_domains_with_app_engine/005_custom_domain.png

Come back to Webmaster Central and press Verify button.

/posts/gcp/using_custom_domains_with_app_engine/006_custom_domain.png

Go back to Google Console and click Refresh Domain. Now you should see it like this.

/posts/gcp/using_custom_domains_with_app_engine/007_custom_domain.png

/posts/gcp/using_custom_domains_with_app_engine/008_custom_domain.png

/posts/gcp/using_custom_domains_with_app_engine/009_custom_domain.png

Now I have to come back to Cloudflare and add the listed above A and AAAA DNS records for testapp.raibis.lt. You have to delete CNAME first, before adding A and AAAA records.

/posts/gcp/using_custom_domains_with_app_engine/010_custom_domain.png

It can take up to 24h while updated A and AAAA propagate. I can check domain propogation status with dnschecker.org testapp.raibis.lt DNS status.

Google certificate generation will fail.

/posts/gcp/using_custom_domains_with_app_engine/011_custom_domain.png

I am using Cloudflare strict encryption mode.

/posts/gcp/using_custom_domains_with_app_engine/012_custom_domain.png

Therefore I have to generate an Origin certificate and add it to App Engine. In Cloudflare raibis.lt > SSL/TLS > Origin Server

/posts/gcp/using_custom_domains_with_app_engine/013_custom_domain.png

Select RSA private key type. Add testapp.raibis.lt to host names.

/posts/gcp/using_custom_domains_with_app_engine/014_custom_domain.png

Clicking Create will create certificates. I have to upload certificate to App Engine.

/posts/gcp/using_custom_domains_with_app_engine/015_custom_domain.png

Upload a new certificate.

/posts/gcp/using_custom_domains_with_app_engine/016_custom_domain.png

Copy/paste the Public key certificate and Private key. Here starts the fun part. You will get a Private key invalid error.

/posts/gcp/using_custom_domains_with_app_engine/017_custom_domain.png

Fortunately this is easy to fix by renaming private key parts -----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY----- to -----BEGIN RSA PRIVATE KEY----- and -----END RSA PRIVATE KEY-----

/posts/gcp/using_custom_domains_with_app_engine/018_custom_domain.png

Upload and enable certificate.

/posts/gcp/using_custom_domains_with_app_engine/019_custom_domain.png

Now you can visit testapp.raibis.lt. Be patient you might get 525 error. In this case, you might need to wait sometime.

/posts/gcp/using_custom_domains_with_app_engine/020_custom_domain.png

While waiting you can check if your SSL Certificate is valid. To view the status of your SSL certificate, you can use an SSL certificate checker tool
/posts/gcp/using_custom_domains_with_app_engine/021_custom_domain.png

Congratulation now you can visit App engine app directly and from testapp.raibis.lt