-2

I am developing an application which process is like below:

  • User do registration
  • System will create a sub-domain as the username registered. i.e : xyz.abc.com
  • User will build his webpage under this sub-domain (xyz.abc.com)
  • if user got a domain (example.com), user will be able to link the domain with the sub-domain that was created during registration.

My Question is: To link the Domain (example.com) with the sub-domain (xyz.abc.com) what need to do? Note: user will browse the domain (example.com) and will view the content from Sub-Domain (xyz.abc.com). Do I need to do CNAME, A Record or ALIAS configuration?

kazi
  • 1
  • 1
  • It would help to know what platform you are developing on and a little more about your environment. Your question sounds a lot like you are wanting tips on managing DNS or like you are trying to build a web interface that manages DNS, but without more information, I doubt you will get an accurate answer. – Bill Nov 15 '17 at 19:27
  • When companies like Microsoft do this, they don't make the DNS changes for the customer automatically, they list instructions for how the customer can do it themselves. That's because usually the DNS is not under Microsoft's control. You might want to do it like the big companies do it, since they do it that way for a good reason. – Todd Wilcox Nov 15 '17 at 20:18
  • 1
    The Application is developing using PHP Laravel Framework. There will be an option for the user to input his own domain and tag the Domain with the Sub-domain he own within my application. If A Record or CNAME requires to update in there own Domain Panel, they will do it and point the A or CNAME to my Web-Application. For specifically they will point there domain to the sub-domain that they own within my application. I could check if the CNAME or A record has been updated using API. @Bill – kazi Nov 16 '17 at 14:42
  • I would like to give instruction to my subscriber how they could point their Domain to the sub-domain they own within my Web Application. So if they own "example.com" and want to point this domain to the sub-domain "xyz.abc.com" they own within my web application. How they can see all the content from sub-domain "xyz.abc.com" by browsing the domain "example.com" ? @ToddWilcox – kazi Nov 16 '17 at 14:46

1 Answers1

0

There are two layers in this.

  1. The web server needs to know the external domain in order to serve the correct content requested in the HTTP Host: header. This is a HTTP protocol thing: DNS can't do this for you as it, in all its forms, only resolves names to IP addresses. The connection to the server is always established using the IP address alone.

    You wouldn't want your users to write freely anything to your web server configuration, so you need to check at least:

    • The syntax: it must be a valid FQDN (minus root .).
    • The maximum sub domain level.
    • That there is a valid corresponding A record in DNS.
    • Whether the user has right to use this domain or not. You could e.g. require an additional example.com. TXT "kazi=userid" record to confirm that someone is not trying to use a domain of another user. (A CNAME instead of A would do this for a sub-domain to sub-domain arrangement, but you can't use it for the domain itself.)
  2. Who is responsible of the DNS? Your question does not state that you are willing to host the DNS for custom domains, as well. For external DNS you must write a proper documentation on what records are required for using your service.

Esa Jokinen
  • 43,252
  • 2
  • 75
  • 122
  • I would like to give instruction to my subscriber how they could point their Domain to the sub-domain they own within my Web Application. So if they own "example.com" and want to point this domain to the sub-domain "xyz.abc.com" they own within my web application. How they can see all the content from sub-domain "xyz.abc.com" by browsing the domain "example.com" ? @Esa Jokinen – kazi Nov 16 '17 at 14:56
  • Exactly as in this answer: by configuring your web server to accept this domain. They can't do it in their DNS configuration alone. You'd have to provide an interface to add own hostnames or add them manually. – Esa Jokinen Nov 16 '17 at 15:07
  • Thanks. Could you please explain this part in another way, "You'd have to provide an interface to add own hostnames or add them manually. –" @Esa Jokinen – kazi Nov 17 '17 at 15:14
  • Otherwise, your webserver wouldn't know which content to serve. – Esa Jokinen Nov 17 '17 at 15:22
  • Okay. So you are suggesting to set host name for each sub-domain? If user-1 own Domain : example.com and got sub-doamin : abc.xyz.com in my web platform. Now he needs to point example.com of this sub-domain :abc.xyz.com ? So that, he could browse domain and see the content of sub-domain ? @Esa Jokinen – kazi Nov 19 '17 at 08:50
  • That's only the part 2. The webserver needs to be aware of this, too. Otherwise it wouldn't know which content to show i.e. the correct user or "subdomain". DNS alone simply doesn't do this, as explained in the answer.. did you actually read it? – Esa Jokinen Nov 19 '17 at 08:56
  • Thanks. I know a little of this term and that is why may be it become hard to understand your point. I read but understand a little. So I need to write a host file each time once a user wants to point his domain to the platform sub-doamin, right ? So the host file could be look like below? 2XX.0.1XX.10 domain_name.com sub-domain_name.com Thanks for the help @Esa Jokinen – kazi Nov 21 '17 at 11:05
  • No. The hosts file is related to the DNS system, too: it's a local replacement, overwrite to the global DNS. You need to add the domain to your web server's i.e. HTTPd's (Apache, Nignx) virtual host configuration. – Esa Jokinen Nov 21 '17 at 11:10
  • Great. I will follow this. – kazi Nov 22 '17 at 11:59