I have a site on Google Domains (www.example.com) and it's hosted with Gcloud. I followed the instructions listed here to set up SSL and https: https://cloud.google.com/appengine/docs/standard/python/securing-custom-domains-with-ssl
Basically, I just ran gcloud beta app domain-mappings update example.com --certificate-management='AUTOMATIC'
Now I can indeed access https://example.com and https://www.example.com. But I can access the unsecure http version of those domains as well.
How can I set up my Google Domain to always use https? If someone types http://example.com, I want it to go to the https site instead.
Records: My naked domain (example.com) has 4 A records and 4 AAAA records.
My www.example.com domain has 1 CNAME record with alias=www.
secure: always
still works in all standard environments, but the secure option has been deprecated in all flexible environments, see documentation here or here for Node.js.If you need this feature in your current environment, the suggested solutions require changes to your application code. Either use the custom HTTP header
X-Forwarded-Proto
to redirect the HTTP traffic to HTTPS, or use the HTTP Strict Transport Security response header.Have you tried setting
secure: always
in your handlers in yourapp.yaml
?https://cloud.google.com/appengine/docs/standard/python/config/appref#handlers_element
Alex's answer (see comments) put me on the right path.
First
meteor add gadicohen:headers
to addheaders
info.In my router logic (Iron Router on Meteor) in a before hook, I check if the
x-forwarded-proto
ishttp
. If so, replacehttp
withhttps
and go to that URL instead. I make sure I'm not on localhost too, so that I can develop the siteNot sure what backend language you are using, but you can brute-force to ssl by checking the request header then redirecting. Example: