Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

namecheap DNS config does not work with https on Heroku custom domain

I'm very confused with how to setup namecheap and heroku so they work together to serve custom domains over https.

I'm using heroku ssl beta, by the end of the configuration, heroku has updated its domain map like this:

myapp.com        myapp.com.herokudns.com
www.myapp.com    wwww.myapp.com.herokudns.com

The ssl certificate has been added to heroku successfully, I know it because I can access https://myapp.herokuapp.com with a green padlock.

The next step should be modifying namecheap DNS, I followed this tutorial

The entries I added are:

CNAME Record    www    myapp.herokuapp.com
URL Redirect    @      https://www.myapp.com

That should be it, but it doesn't work as I expected.

If I type myapp.com, it goes to https://www.myapp.com (so the redirect works), but without a padlock.

The same if I go to https://www.myapp.com directly.

I'm sure it's not because the change hasn't taken effect yet, because I have messed around with other domains and it already take effect after 5min or so.

Can someone please tell me what is the problem?

like image 443
swang Avatar asked Jun 03 '16 14:06

swang


People also ask

How do I force https Namecheap?

1. Go to cPanel > Exclusive for Namecheap customers section > Namecheap SSL: 2. Next, click Installed via plugin and switch HTTPS Redirect toggle on.

How do you point your DNS provider at the DNS target provided by Heroku?

Summary of steps Add the custom domain to your app with the heroku domains:add command. Look up the Heroku-supplied DNS target for the custom domain using the heroku domains command. Configure your app's DNS provider to point to the Heroku-supplied DNS target. Confirm that your app is accessible via the custom domain.

Does Namecheap work with Heroku?

It is also possible to make your app accessible via a custom domain that is registered with Namecheap. Here you can add custom domains to both free and paid Heroku accounts. Domains can be inspected and managed using either Heroku CLI or Dashboard.


2 Answers

I found out what's wrong, after uploading ssl certificate to heroku, I should stop using myapp.herokuapp.com, instead use myapp.com.herokudns.com, so in namecheap's DNS config, I should have the following:

CNAME Record    @        myapp.com.herokudns.com
CNAME Record    www      www.myapp.com.herokudns.com

I don't think the redirect is necessary (even in Namecheap's document it says you should not set CNAME on bare domain, but should redirect www instead). I tried to use URL redirect record www https://myapp.com to replace the www CNAME record but it won't work.

Besides, when I created the certificate with lets encrypt, I only certificated domain myapp.com, but forgot www.myapp.com, so when access www domain, the browser complains certificate is from myapp.com, once I expanded the certificate to cover www.myapp.com, with the above config, all domains works fine with a green padlock.

like image 96
swang Avatar answered Nov 16 '22 03:11

swang


Your solution (using CNAME for @) in Namecheap works for https fwding to amazon ELB instances too. My domain is served by Namecheap. Their recommendation (incorrect as you pointed out) was to URL fwd https traffic for my domain (x.com) to my amazon elb instance (which has my ssl cert for x.com). URL fwding gets a conn refused error from NameCheap's servers.

Using a CNAME for @ displays a nice green secure seal for https URLs. I also added a CNAME www to the same amazon elb instance for non-https traffic.

like image 35
Sanjay M.K. Avatar answered Nov 16 '22 02:11

Sanjay M.K.