Home
Support Forums

Support for wildcard domains and multiple custom domains

Dear Support

We are in love with netlify features, current we are using render.com. We love that render has the following features

Would like to know if that is possible in netlify, went. thru the forum but did not find a clear answer to this

regards
Mak

Multiple custom domains is possible, but are we talking about linking all those domains to the same Netlify website? For example, customdomain1.com and customdomain2.com should point to the same Netlify website? If yes, both those addresses will show the same website and would be redirected to the domain set as the primary one. Also, that’s limited to 99 domains per website, I suppose.

While creating subdomains is possible, you’ve not mentioned how you’re planning to create those subdomains.

If you can details about your use-case I’m sure the support team can work out a solution.

If you’re planning to create an individual website for each of the client, I think there’s a limit for 350 websites per account which exists to prevent spam and can later be increased by the support team.

Afaik you can use branch deploy to deploy to sub domains.

If you have your default branch ,usually aka master, deployed to example.com, and you have a branch staging, then you can deploy it to staging.example.com.

It is easy to work with if you only need some sub domains.

It can be tricky to do it dynamically though, if you want to automatically create sub domains for each of your clients/customers/users (like what netlify do). You need to play with git with your own backend server and play with netlify API after a successful git push. Anyway, I don’t think you should play with your git repo like this.

So, if you need dynamic sub domains, you might need to do it with your own server and probably your own DNS.
(Maybe you can try playing with CloudFlare and CF worker, but, I don’t know, I am not using CF pages).

I am sorry I am more confused now, could you advise does netlify support

*.myapp.com

so I have the same deployment and n number of clients

Again, you’re not describing your use case.

If you mean all those subdomains pointing to a single website, then there’s a limit of 99 domains (not sure, but something around those numbers).

If you mean each subdomain pointing to a new website, there’s a limit of 350 websites (again, not very sure).

If you mean that you’re going to use Netlify just to manage DNS and point the subdomains elsewhere, it’s supported but there might be some restrictions there too.

If you describe your use case in detail, there are more chances of you getting a correct answer because without your use case, we’re just guessing.

Thank you for a quick response.
The use case is, all those subdomains will point to the same website, based on the subdomain we will have a different account populated.
Each subdomain is a client of ours, if there is a limit of 99 domains to it, that will feasible case then.

On top of that, if a client says he needs a custom domain, in that case, that custom domain will also point to the same website

Let us know how can we address it

Okay so, if all sub-domains are going to be added to the same website, it’s probably not possible. On Netlify, you can add about 90+ custom domains to the same website, but you can set only one of those as the Primary domain. All the other domains are redirected to the primary one. So, no matter which of those 99 domains you enter in the address bar, you’ll get the exact same website. You might want to reconsider the sub-domain routing in this way.

However, if you create a different Netlify website for each of these clients and manage your DNS elsewhere, I think you can create those many individual websites and point those sub-domains to each of that website. Since you’re fine with the limit of 99 domains, I am considering you’d have a total number of websites less than 99. In that case, there should be no problems setting that up.

So I understand what you want.

You can create a wildcard record pointing to your domain, if it is your and let your server reads its host header to decide what to do, if it were your own server.

It may not work with netlify though, probably wildcard CNAME won’t work. Maybe there can be a wildcard NETLIFY record on netlify’s DNS setting.

Anyway, why must you make it a subdomain instead of a path ?

I confirmed that (using only) wildcard CNAME record would not work with netlify:
It resolves correctly, and points to netlify IP, but netlify cannot find what to serve, instead, it returns this:
Not found - Request ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx-xxxxxxx

And you cannot just create a wildcard NETLIFY record, there is no such option.

Hey @yw662, the wildcard subdomains, which would use a wildcard CNAME, is a feature we can enable for Pro or higher accounts :slight_smile:

@mak here’s a bit more info for you on the feature, please feel free to follow up if there are more questions:
The wildcard subdomains feature is one we can enable on a Pro account or higher. This means you could have a custom subdomain for each of your customers, i.e. customer1.yourstore.com, customer2.yourstore.com, etc. all pointing to the same underlying site. If you’re using Netlify DNS to host your DNS, we can take care of the SSL certificate for this configuration. Otherwise, you’ll need to bring your own wildcard SSL certificate.

A few caveats about this feature:

  • You can’t use domain aliases on a site with wildcard subdomains enabled, just the bare domain and subdomains under your primary domain. If you try to add a domain alias then it won’t work.
  • The primary custom domain for the site, if it is a “site.com+www.site.com ” setting in our UI, must be www.site.com and NOT site.com!

Let us know if this helps or if we can answer any other questions!

2 Likes

Got it, thank you,

So as of now when a client signs up for an account(say at myproduct.com), we give him an url
client1.myproduct.com
and then when he requests for a custom url, say app.client1.com, we then add a DNS entry and redirect client1.myproduct.com => app.client1.com

I understand, you are saying this is not supported.

Alternative Solution
Lets say when a client signs up, we will give him is url as
app.myproduct.com/client1

In that case, is Customdomain possible.

Do suggest alternatives as well

Actually it is possible. It is possible for pro or higher account:

For implementation, if you would like to redirect (\d+).myproduct.com to app.$1.com, you can use a function to return 301/302. It is too tricky to dynamically create CNAME records for it though.

That is possible, as what I posted. You create a branch app, make a function to handle it (maybe let’s call it /.netlify/functions/clients), and make a redirect rule from /* to the function /.netlify/functions/clients, and that is it.

So with the Pro account wildcard domain support is available, and if we host DNS in netlify the certificate renewals are also not a problem, that’s great.
But with this solution domain alias (custom domains) is not possible

Alternative solution,
With the redirect approach, anybody who visits the client’s account(client1.myproduct.com) will get redirected to the custom domain.

And what will be the domain configuration for custom domain look like

For domain part it should be just like this:

And whatever the “enable wildcard domain for pro account” after that.

For 302 part, you need a lambda function I think, since you need to read host header and compute redirect address from it.

my bad, the alternative solution was path based
so it was
app.example.com/path1

Now if it need to point this to a custom domain, how will that look like.

The path you mentioned, above is interesting as well, so with that custom domain is possible?

Surely it is possible, but I cannot demonstrate it since I don’t have a pro account.

You can create a lambda function, whose handler will check host header and do the redirect:

disclaimer: the code below is completely improvised, not checked and tested at all, and may contain (even) syntax errors

exports.handler = event => ({
    statusCode: 301,
    headers: {
        Location: `https://app.${event.headers.host.split('.')[0]}.com/`
    }
})

And here is the netlify.toml where you tell netlify about how to use this function:

[build]
functions = "where the the js file is"

[[redirects]]
from = "/*"
to = "/.netlify/functions/clients"
status = 200

Thank you, so much

Here are the findings, please find the conclusion

  • Wilddomains *.yourproduct.com is possible
  • Custom domains - www.client1.com opening the same site as *.yourproduct.com (this is pointing to same website and not a redirect) is possible for 99 customers\
  • We can use powerful lamda redirects to redirect to a custom website if need be