Setting Google domains to use https
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
Related videos on Youtube
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, 2022Comments
-
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 fromhttp://mysite.example.com
tomysite.herokuapp.com
works just fine.Recently, I need to introduce
progressive-web-application
to my application and it requires thehttps
protocol, instead ofhttp
, that is, the URL now has to behttps://mysite.example.com
and it doesn't work for Google domains. I triedhttps://mysite.herokuapp.com
and it works fine, which means Heroku already supportshttps
. 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 about 6 yearsHi, 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 about 6 years@SugarTang how will someone help you when you don't even reply back?
-
Bastien Robert about 6 yearsDid you try to
heroku certs:auto:enable
on your app from the Heroku CLI tool ?
-
-
Randy Tang about 6 yearsI've add
SECURE_SSL_REDIRECT = True
insettings.py
, and there is alreadydjango.middleware.security.SecurityMiddleware
inMIDDLEWARE_CLASSES
. But it doesn't seem to work. The error message: "NET::ERR_CERT_COMMON_NAME_INVALID" -
Randy Tang about 6 yearsblog.heroku.com/ssl-is-now-included-on-all-paid-dynos, so I don't think I have to create certificate for myself.