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.
Set SECURE_SSL_REDIRECT to True, and enable the SecurityMiddleware in your app, and any requests should automatically be redirected from HTTP to HTTPS. Save this answer. Show activity on this post.
In the Google Cloud console, go to the Custom Domains tab of the App Engine Settings page. Click Add a custom domain. If your domain is already verified, the domain appears in the Select the domain you want to use section. Select the domain from the drop-down menu and click Continue.
In the list of frontend hosts, select the custom domain you want to enable HTTPS for containing your custom domain. Under the section Custom domain HTTPS, select Enabled, and select Front Door managed as the certificate source. Select Save. Continue to Validate the domain.
Have you tried setting secure: always
in your handlers in your app.yaml
?
handlers:
- url: /youraccount/.*
script: accounts.app
login: required
secure: always
always
Requests for a URL that match this handler that do not use HTTPS are automatically redirected to the HTTPS URL with the same path. Query parameters are preserved for the redirect
https://cloud.google.com/appengine/docs/standard/python/config/appref#handlers_element
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With