Search code examples
herokudnssubdomainnamecheap

configuring namecheap domains with heroku


I have a app on heroku(paid dyno):

https://example.herokuapp.com/

I have purchased a domain:

www.example.com

After reading multiple guides I can't figure out how to do the following:

  • point domain to my heroku app(with SSL)
  • configure a subdomain like api.example.com

The overall goal is to have a domain like api.example.com

Thanks. NOTE: Please do not simply link to documents from heroku and namecheap. I have read them all, and they are out of date/unspecific.


Solution

  • I have just done something similar recently and I think it's what you need. In my case, I need to turn on SSL ACM (Automatic Certificate Management) for my existing heroku app.

    First, you need to turn on Automatic Certificate Management to get the SSL certificate from heroku.

    • Check if ACM is on

      $ heroku certs:auto -a [your app name]
      === Automatic Certificate Management is disabled on [your app name]
      
      Note: if you don't have heroku-toolbelt installed, just ignore this step. It's just a check.
      
    • Go to heroku dashboard's Settings

    • Click on 'Configure SSL' button
    • Choose ACM and click continue
    • Click 'Add domain' button if api.mysite.com is not already there.
    • Take note of the 'DNS Target' which is something like api.mysite.com.herokudns.com
    • Check certificate status again

      $ heroku certs:auto -a [your app name]
      === Automatic Certificate Management is enabled on [your app name]
      

    Second, you need to login to your namecheap dns zonefile page and add a CNAME.

    • Change CNAME to 'api' record to point to api.mysite.com.herokudns.com (or whatever is there in the DNS Target above)

      TYPE        NAME        VALUE
      A           @           10.10.10.10                         <<< your www ip 
      CNAME       api         api.mysite.com.herokudns.com        <<< you need this one.
      
    • Wait 10 mins

    • Browse to api.mysite.com