ruby-on-railsherokudnssubdomainnamecheap

Create a subdomain on Namecheap for a Heroku Rails app


I have a domain name registered on namecheap. Let's say it is mysite.com. I want this domain to be my personal site. I also want to create a subdomain like myapp.mysite.com for a Rails app on Heroku.

I have tried to configure one in the DNS section of the Namecheap dashboard but I'm new with theses things. I'm using a CNAME type, @ for host and automatic for TTL.

I have also added myapp.mysite.com as a custom domain in my Heroku dashboard.

Am I doing this right? Please explain it in detail so I can learn more about DNS.

EDIT:

I have changed my subdomain like this:

  1. Type: CNAME
  2. Host: myapp
  3. Value: mysite.om
  4. TTL: Automatic

Since the DNS has updated, I now get a 400 bad request error from Nginx. Is it because of Heroku? Do I have to add some setting in Heroku?


Solution

  • I have found the solution for my question. So first of all, the correct configuration for the advanced DNS:

    1. Type: CNAME
    2. Host: myapp
    3. Value: myapp.herokuapp.com (without the https protocol)
    4. TTL: Automatic

    After that, it takes a moment for the DNS to update the subdomain and make it available. During this time, I needed to add my subdomain to my Heroku configuration. It is possible via the dashboard of via terminal.

    I did it via terminal with this command: heroku domains:add myapp.mysite.com

    After some time, it finally worked. However, having a custom domain or subdomain disable the default SSL from Heroku.

    I mostly learn via this article: https://devcenter.heroku.com/articles/custom-domains