Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Google domains to use https

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?

like image 216
Randy Tang Avatar asked Mar 26 '18 14:03

Randy Tang


People also ask

How do I force Google domains to HTTPS?

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.

Do Google domains have Free SSL?

The following Google services automatically issue, install and renew SSL/TLS certificates at no additional cost: Google Sites. Google Business Profile. Blogger.


2 Answers

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.

like image 182
Bernhard Avatar answered Oct 01 '22 13:10

Bernhard


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.

like image 28
Stobor Avatar answered Oct 01 '22 12:10

Stobor