DEV Community

KaMeHaMeHA
KaMeHaMeHA

Posted on

Noob here - how to let users point their custom domain to my application?

Sorry if this question is too broad or vague.
How do we just like shopify, let our users connect their own custom domains and point it to their store made on our app.

Right now, it opens under our own domain as a subpage, but I want it to be completely accessible through their custom domain, (even when being opened through the subpage url - it should redirect to their connected custom domain).

  • Should auto issue SSL certificates to their domains.
  • Need to do it without using any paid third-party service
  • Should be very cheap or virtually free.

- I've heard it's a feature offered only by AWS but are there ways to do the same on other hosts too like vulr, DO, linode

Bonus Question - How do big dogs like shopify, blogger and all these services that let users connect their own domain to their page do it?
It's works efficiently, they only ask to add some (a records/c names) and there's a refresh button to check whether changes have been made.

I want to know the entire flow, right from start from to how it analyzes domain's dns and connects the page to that domain and so now it looks just like a separate website.

We are using heroku
Firebase realtime
Express,
React js,
Node js

Also, I'm still learning, so please excuse if I used some wrong terms.

Top comments (4)

Collapse
 
phlash profile image
Phil Ashby

Big question 😁 I'll see if I can outline the flow without obscuring everything with too much detail (I have previous experience of managing both DNS and web hosting, and currently host my own content in Azure using custom domains):

  • Assuming the customer manages their own DNS, they have some prep work:
    • Add or update a DNS record with an ownership proof token that your system has provided. This is typically a new TXT record, or a custom CNAME with the token in.
    • Add or modify a DNS CNAME record for the custom domain, that aliases the custom domain name to your hosting service name.
  • Now they can enter the custom domain name into your system, where you:
    • Collect the ownership proof token from their primary DNS (via NS records) and check it's valid (fail if not!)
    • Configure your hosting platform to map requests for the custom domain (indicated by one or both of server name indication and Host: <domain> header) to their content.
    • Create and sign a TLS certificate for the custom domain, either by being a trusted certificate authority (like Azure) or by operating the LetsEncrypt ACME over HTTP validation process, then configuring the hosting platform to return this certificate for the custom domain.

Simples :)

Collapse
 
kamehameha profile image
KaMeHaMeHA • Edited

Thanks a lot for the explanation.

I had some rough idea how this works.
Only thing Idk how to go about it. I want to know how do I do it:

  • How to get my own TXT record/CNAME that users can update their domains with to prove ownership of their domain.

  • How to collect ownership proof token and How to check if it's valid

  • Configure hosting platform to map requests for custom domain - but how?

Is there any in depth guide on this? It would help me immensely.
I know it's a tall ask but can you help with this or share tutorial/guide on this. Thanks once again! You're truly amazing!

Collapse
 
phlash profile image
Phil Ashby

As usual with this sort of thing, it depends greatly on your technology platform(s), development language etc. etc. but the fundamental pieces are:

  • A DNS client library that let's you look up information about a specified domain (tools like nslookup and dig do this, a C programmer might use glibc's resolver API) this is used when collecting the token from their primary DNS (note, nothing to do with your own service DNS settings).
  • A hosting platform / web server technology that supports virtual domains (Apache, NGiNX, IIS all do this, large orgs like Azure have got their own proprietary software), and that can be configured by automation (possibly via 3rd party tools like Ansible or Chef)
  • Your own website (can be on the same platform as your users of course) that supports user accounts, where you can maintain the necessary addtional data (ie: custom domain list, each with configuration state and ownership token data), present your users with their info so they can do their bits, and invoke the required automation to configure your hosting platform when required (mapping content, deploying certs).

Sorry I cannot provide any turnkey examples of this, and neither can popular search engines it seems, probably because it's unusual to be doing this yourself... 😁

Thread Thread
 
kamehameha profile image
KaMeHaMeHA • Edited

Thanks again, I think I'm getting a rough picture on how now.
by the way,
We are using
Firebase realtime
Express,
React js,
Node js
heroku netlify for hosting

If you have any additional tips to share, I'd appreciate it.