# Multi tenant - custom domain issue

**URL:** <https://community.fly.io/t/multi-tenant-custom-domain-issue/9809>\
**Category:** Questions / Help\
**Created:** [January 4, 2023, 8:52am UTC](https://community.fly.io/t/multi-tenant-custom-domain-issue/9809 "2023-01-04T08:52:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![piotrkulpinski](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/piotrkulpinski/32/35749_2.png) [@piotrkulpinski](https://community.fly.io/u/piotrkulpinski)\
**Post date:** [January 4, 2023, 8:52am UTC](https://community.fly.io/t/multi-tenant-custom-domain-issue/9809/1 "2023-01-04T08:52:48Z")

</div>

Hi,  
I’ve built a multi-tenant app and pointed a wildcard subdomain to the fly’s IP like \*.example.com  
This allows me to have a new subdomain for each user like [first-tenant.example.com](http://first-tenant.example.com).

I’m also offering a custom domain feature in the app and using fly’s API to add new certs everytime user adds a domain in the system.

I then advise them to add a CNAME record pointing from their domain to [first-tenant.example.com](http://first-tenant.example.com)

Unfortunately, this doesn’t work and I have no idea why. It only works if I give them the fly’s IP address to set as A record and \_acme-challenge to add as well.

Please advise 🙏

Thanks!

---

<div class="post-metadata">

**Author:** ![piotrkulpinski](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/piotrkulpinski/32/35749_2.png) [@piotrkulpinski](https://community.fly.io/u/piotrkulpinski)\
**Post date:** [January 9, 2023, 11:47am UTC](https://community.fly.io/t/multi-tenant-custom-domain-issue/9809/2 "2023-01-09T11:47:23Z")

</div>

Would love to get some feedback here 🙏

---

<div class="post-metadata">

**Author:** ![piotrkulpinski](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/piotrkulpinski/32/35749_2.png) [@piotrkulpinski](https://community.fly.io/u/piotrkulpinski)\
**Post date:** [January 9, 2023, 11:56am UTC](https://community.fly.io/t/multi-tenant-custom-domain-issue/9809/3 "2023-01-09T11:56:52Z")

</div>

I mean, the \_acme-challenge record is set as optional, but it is required for me to make the domains work.

 ![CleanShot 2023-01-09 at 12.56.04](https://global.discourse-cdn.com/fly1/original/3X/e/e/eee21d5a670b33c3b2e626c98653428d5ebe1c8c.png)

---

<div class="post-metadata">

**Author:** ![jerome](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/jerome/32/17_2.png) [@jerome](https://community.fly.io/u/jerome)\
**Post date:** [January 9, 2023, 1:53pm UTC](https://community.fly.io/t/multi-tenant-custom-domain-issue/9809/4 "2023-01-09T13:53:13Z")

</div>

Does it work for some hostnames?

CNAME flattening does not work from all DNS providers IIRC. Meaning if they set a CNAME on an apex domain (no subdomain), then it might not work. The subject is broached [here](https://fly.io/docs/app-guides/custom-domains-with-fly/#option-i-cname-records).

Some providers call that an `ALIAS` record and it does work.

You’ll probably need special instructions for your users to set A and AAAA records directly when they are using an apex domain.
