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?

Upvotes: 2

Views: 1961

Answers (2)

Kyle Venn
Kyle Venn

Reputation: 8038

The selected answer didn't work for me. But following the docs did.

  1. Open terminal
  2. heroku domains:add www.example.com
  3. host www.example.com
  4. Copy the url that looks like: whispering-willow-5678.herokudns.com
    • Note It will always be suffixed by .herokudns.com
  5. Add a CNAME Record with the host (www, in my example).
  6. Paste in the url you copied under Value (see screenshot below).
  7. Click the check mark on Namecheap
  8. Profit

Resources

Heroku DNS

Upvotes: 0

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

Upvotes: 3

Related Questions