I purchased a domain (say, example.com
) from Google and my Django application (say, mysite.herokuapp.com
) runs on Heroku. The CNAME is set on Google to forward the http requests to the Django applicaiton on Heroku. Forwarding requests from http://mysite.example.com
to mysite.herokuapp.com
works just fine.
Recently, I need to introduce progressive-web-application
to my application and it requires the https
protocol, instead of http
, that is, the URL now has to be https://mysite.example.com
and it doesn't work for Google domains. I tried https://mysite.herokuapp.com
and it works fine, which means Heroku already supports https
. However, I tried (and also googled) for a long time without finding a solution.
So how do I set the Google domain to use https
protocol?
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.
The following Google services automatically issue, install and renew SSL/TLS certificates at no additional cost: Google Sites. Google Business Profile. Blogger.
The DNS answer from Google cannot contain the port or protocol (http vs. https), it just contains the hostname.
You need to add a redirect from http to https in the Heroku django app, see e.g. here for more instructions.
It's not Google you need to change, it's your Django configuration.
Set SECURE_SSL_REDIRECT to True, and enable the SecurityMiddleware in your app, and any requests should automatically be redirected from HTTP to HTTPS.
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