How to Set Up a Wildcard Subdomain on Heroku

03.16.2015

Recently, I needed to get subdomains to work on Heroku for a multitenant application. It might be slightly more expensive, but I highly recommend DNSimple over other services for a few reasons. DNSimple supports ALIAS records, which allows you to use the root domain. They also support wildcard subdomains. And things just work. No need to contact support to set up wildcard domains. DNSimple makes DNS simple. Outlined below is the general process for getting the DNS stuff set up.

Step 1: Learn how to work with subdomains in Rails.

Follow instructions in railscast http://railscasts.com/episodes/123-subdomains-revised.

Step 2: Deploy your heroku app.

Step 3: Add the subdomain.

heroku domains:add *.your-domain.com

Step 4: Sign up for DNSimple account.

Step 5: Register a domain

 Click add domain.

Make sure “register or transfer this domain” is checked, otherwise you might end up adding a domain that isn’t even registered and wonder why things aren’t working.

Register the domain if it is available.

Step 6: Add Heroku service in DNSimple.

Click services and add heroku service.

Enter your heroku app.

Click on your domain.

Click on DNS.

Click Manage records.

Add a CNAME record for *.your-domain.com pointing to your-app.herokuapp.com.