1

I have just set up a custom domain for my Google App Engine, using a domain I bought from GoDaddy. Then I transferred the nameservers to Cloud DNS and inserted the DNS records as the cloud documentation suggested into the cloud DNS record set, and it is working fine.

However, the problem is that when I use the custom domain, it doesn't default to the HTTPS version of the site, I have to manually type in HTTPS (ie I can't just go to example.com, I have to go to https://example.com).

What could I be doing wrong here?

Thank you!

Topographical
  • 159
  • 11
  • You haven't indicated if you followed the instructions or the troubleshooting steps in the [documentation](https://cloud.google.com/appengine/docs/standard/python/securing-custom-domains-with-ssl). – BrettJ Jan 12 '19 at 16:45
  • Possible duplicate of [How to fix google cloud ssl issue](https://stackoverflow.com/questions/54148472/how-to-fix-google-cloud-ssl-issue) – Thusila Bandara Jan 14 '19 at 08:21

2 Answers2

5

App Engine standard environment

Add the following two lines to your app.yaml:

secure: always
redirect_http_response_code: 301

App Engine flexible environment

You will need to setup HTTPS redirects from within your web server app. Each server node.js, django, Flask, etc. has their own method of handling HTTPS as the only protocol.

BrettJ
  • 6,801
  • 1
  • 23
  • 26
John Hanley
  • 74,467
  • 6
  • 95
  • 159
  • Thank you! I would never have known this. Works like a charm. – Topographical Jan 13 '19 at 08:27
  • Are any other Java developers frustrated that `appengine-web.xml` seems to compile into an `app.yaml` but we can't setup the `secure: always` and `redirect_http_response_code: 301` from our `appengine-web.xml`? – Anthony Chuinard Jul 15 '19 at 06:10
  • 1
    For rookies like myself - code has to be under url tag: `- url: /.* script: auto secure: always redirect_http_response_code: 301` – Aseem Sep 18 '19 at 04:08
1

For rookies like myself :- In app.yaml file you already have first 2 lines of following code. Add last to lines under it:

- url: /.*  
  script: auto  
  secure: always  
  redirect_http_response_code: 301

Reference : app.yaml file documentation All urls will get redirected for https secure connections

Aseem
  • 5,848
  • 7
  • 45
  • 69