0
votes

I have an application where users get their own subdomain, like site1.mysite.example. I would like to allow users to register a custom domain that they can point to to their sub domain but I'm having trouble figuring how to configure Heroku and my DNS settings to allow this.

In my DNS settings for my domain I have a CNAME record setup like so:

Host = *

Value = sites.mysite.example

The value here is an app I have running which will translate the subdomain (site1.mysite.example) to figure out which site to load.

I have a CNAME for mysite.com which points to Heroku's DNS site:

Host = sites.mysite.example

Value = mysite.example.herokudns.com

On the domain I'm testing with I have a CNAME record setup like this:

Host = docs.othersite.example

Value = site1.mysite.example - this is the subdomain they get on my site

But for some reason this is not working. If I register site1.mysite.example as the custom domain in my application and I run dig site1.mysite.example I get the following:

;; ANSWER SECTION:
docs.othersite.example IN CNAME site1.mysite.example
site1.mysite.example   IN CNAME sites.mysite.example
sites.mysite.example   IN CNAME mysite.example.herokudns.com.

When I try docs.othersite.example in a browser I get Heroku's There's nothing here, yet. page. So it seems like Heroku is not loading up my application. I am guessing this is because I do not have docs.othersite.example registered as a domain in my Heroku application, but I do not want to have to register every custom domain. Also, I do not own these domains so I could not anyway.

What am I doing wrong here? Any help is much appreciated. I'm happy to post any more info someone needs or clarify anything.

1
I was able to get this working by adding the domain docs.othersite.example in my Heroku app's registered domain names. While this seems to work I have to add a custom domain name to my Heroku app anytime someone updates their custom domain in my app. I'm wondering if there's anyway around this so I don't have to add a custom domain everytime?officert

1 Answers

0
votes

Heroku does support wildcard domains, so in this case you could add *.othersite.example to your Heorku app's custom domains.

If you need to support different root domains (othersite2.example, othersite3.example) for each user, there's no easy way to support that. You'd need use Heroku's Platform API to programmatically manage custom domains.