Setting Google domains to use https

11,515

Solution 1

Just got a solution from one of Heroku's engineers:

1) Upgrade the Heroku app to a paid one (e.g., Hobby)

2) On the DNS provider's settings, set the DNS target to <app_name>.<domain>.herokudns.com (e.g., "mysite.example.com.herokudns.com")

3) Run $ heroku certs:auto:refresh -a <app_name> (e.g., $ heroku certs:auto:refresh -a mysite)

Solution 2

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.

Solution 3

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.

Solution 4

When switching to HTTPS you need to add certs to heroku and that process updates the host from "mysite.heroku.com" to something like "tokyo-2121.herokussl.com". You will need to update your DNS to serve HTTPS pages from the new SSL compliant heroku instance for both HTTP and HTTPS.

Here is a tutorial that outlines the process with Godaddy, it should be very similar or all DNS providers.

http://www.joshwright.com/tips/setup-a-godaddy-ssl-certificate-on-heroku

Share:
11,515

Related videos on Youtube

Randy Tang
Author by

Randy Tang

I am interested in web development using HTML5, CSS3, jQuery, Python, Django, Postgres, Heroku, and Amazon S3 and SES.

Updated on June 04, 2022

Comments

  • Randy Tang
    Randy Tang almost 2 years

    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?

    • df778899
      df778899 about 6 years
      Hi, what's the error you're seeing? If it's certificate errors, clearly you'll need to add a certificate and private key (and possibly the intermediate certificates in the certificate chain) for example.com to Heroku - instructions here.
    • Tarun Lalwani
      Tarun Lalwani about 6 years
      @SugarTang how will someone help you when you don't even reply back?
    • Bastien Robert
      Bastien Robert about 6 years
      Did you try to heroku certs:auto:enable on your app from the Heroku CLI tool ?
  • Randy Tang
    Randy Tang about 6 years
    I've add SECURE_SSL_REDIRECT = True in settings.py, and there is already django.middleware.security.SecurityMiddleware in MIDDLEWARE_CLASSES. But it doesn't seem to work. The error message: "NET::ERR_CERT_COMMON_NAME_INVALID"
  • Randy Tang
    Randy Tang about 6 years
    blog.heroku.com/ssl-is-now-included-on-all-paid-dynos, so I don't think I have to create certificate for myself.