We have got a multi-tenant architecture ready with Laravel Framework (i.e when a new users register a new subdomain is created and it's working fine)
Now if the user(hello) wants to access his account, they can go to hello.oursaas.com and see their website.
But how do they achieve the same if they want their own website "hello.com" (not a subdomain), to be pointed to our hello.oursaas.com??
(That means when any user goes to hello.com, the address bar shows hello.com, but the content is of hello.oursaas.com)
How does Shopify do this? (I have a bit idea)
they ask their users to change the A record to point to the Shopify's IP (we can do the same)
they also ask the users to create a CNAME record of WWW and point to shop.shopify.com(this is where we are not able to understand what is happening behind this layer)
Any insights on this will be useful.
I had a very similar setup on Kampsite and ended up using CNAME's (mainly because my users would host it on a subdomain on their domain). So basically I created a cname record on my DNS e.g.
cname.kampsite.coand would have users point a CNAME there e.g.feedback.theirapp.com. If a user was using their root domain e.g.theirapp.comthen it would be an A record.The next thing you need to figure out though would be SSL certificates. Since I had them point to my netlify account, I could programatically add their domain to the site that hosted
cname.kampsite.cowhich would automatically generate an SSL certificate for them, otherwise you could use something like lets encrypt manually yourself OR via something like caddy.@hlucas pretty much nailed it, though I do want elaborate a bit on
Arecords vsCNAMEs:The reason Shopify provides an IP to create an
Arecord rather than aCNAMEis because technically you cantCNAMEthe root of a domain (e.g. "example.com") to another domain [1]. Some DNS providers may allow you to do so, but you'll likely run into problems down the road; email service providers seem to be very particular about it from my experience.Just make sure that if you DO provide an IP, that it is static and that you can keep in indefinitely!
Under the hood this is the same as them asking you to create an
Arecord - only difference is that sincewwwis a subdomain and not the root, it can be aCNAMErecord. Somewhere in their loadbalancer/stack they're looking at theHostheader of the http request to know where to route things to and ifwww.yourstore.commaps to a shop in their system.[1] https://www.freecodecamp.org/news/why-cant-a-domain-s-root-be-a-cname-8cbab38e5f5c/#cname-limitations
Thanks for this!
This is a great question and one that we had to solve last year too.
Our product is a hosted CMS, so it's probably a similar infrastructure concept as yours.
Our app has a specific IP address (we in fact have two because we use AWS Global Accelerator https://aws.amazon.com/global-accelerator/) so we have them point the A record for their apex domain to our primary IP.
We have a subdomain (sites.branchcms.com) set up that is a CNAME for the AWS Global Accelerator subdomain. That essentially also uses the same IP that the apex domain A record would use, but where Global Accelarator gives you two IPs, it uses both IPs as fallbacks.
Here are the instructions we provide to customers. https://www.branchcms.com/learn/docs/overview/dns
You could, of course, have them set both the apex domain and the "www" subdomain as an A record pointing to your IP address. We chose to have "sites.branchcms.com" and have them do a CNAME record because it gives us a brandable record and also allows us to make any changes to the DNS for sites.branchcms.com if we need to.
I hope that helps. If not, let me know.
This is exactly the problem I am struggling with for my wifes project knoww.me . I don't have better answer than others, but I made some progress with CaddyServer hosting multiple domains. This only working with static sites and a bit headache to deal with, so I am searching for any providers who can simplify this process. ex: https://tinny.host
https://fly.io will make things simpler
Thank you fly.io is interesting.
This comment was deleted 5 years ago.