I'm trying to make a website that allows you to setup a photo gallery with a custom domain name.
Users of the site don't know how to register or configure domain names, so this has to be done for them.
User enters desired domain name in a box (we check if it's available) and click 'register' button and our website registers the domain name for them and sets up the website automatically (when user goes to that domain name, the photo gallery just works, no technical skills needed).
Anyone can buy a domain name. To do so, you visit a domain name registrar, such as A2, GoDaddy, or Namecheap, key in the domain you want to buy, and pay a fee. You can't buy just any domain, of course—only one that isn't already registered by another person or business and that bears a valid domain suffix.
What is a DNS API? A DNS API is an Application Programming Interface that lets you manage domains, SSL certificates, and DNS records via a programming language. A DNS API lets you automate the configuration of email records, web hosting, and other services related to your domain.
An API's custom domain name can be the name of a subdomain or the root domain (also known as "zone apex") of a registered internet domain. After a custom domain name is created in API Gateway, you must create or update your DNS provider's resource record to map to your API endpoint.
The Google Domains Express Checkout API lets your customers find, buy, and connect a domain name to your web service in a few easy steps.
Enom has an API for resellers which could let you automatically register a domain on behalf of a user. (I have no affiliation with eNom, nor have I used eNom's products).
Implementation of *.weebly.com
Typically this form of dynamic sub-domaining will use a Wildcard DNS record. This type of record maps a wildcard pattern like *.example.com
to one or more servers.
Let's say you have a blogging site and want to let users choose domain names dynamically. You put up a webpage on www.example.com with a form to let user's select names. So a user signs up and chooses bar.example.com
.
Suppose your DNS server has the following mappings:
foo.example.com > 1.2.3.1
*.example.com > 1.2.3.2
Any request for foo.example.com will route to 1.2.3.1, but any other name, such as bar.example.com, will be served by 1.2.3.2. So when the user is redirected to http://bar.example.com
the browser will hit 1.2.3.2. Note that since no DNS changes needed, there is no propagation delay: the redirect will work instantly.
The software running on 1.2.3.2 would then examine the Host
header in the request, parse the fqdn and strip off .example.com
, and resolve bar
against a database. If a record exists, it will serve up the appropriate response for bar
.
You'd also want to keep a list of reserved names or patterns you plan to use in the future, like www\d*, mail\d*, ns\d*
, so that when a user tries to register the site www07
your blacklist will reject it.
Mapping any domain to bar.example.com
Once the bar.example.com
site exists, the user may want to map a custom domain name like www.widgetsimakeinmyhome.com
to their site. The registration and setup for this is mostly manual, and sites like EasyDNS make it pretty simple. Some registrars may have APIs to make part of this easier for you. These should typically be RESTful or at least HTTP-based APIs, so you can choose which client library you like to use (e.g. urllib2
).
To create the mapping, your database would have a table mapping primary sites like bar
to one or more domain aliases. A person would sign-in and map www.widgetsimakeinmyhome.com
to bar
.
Now your software needs to check the Host
header against both the primary site table and the alias table to resolve to the correct site.
There is no general API for this. You have to check back with your own domain registration organization. This is specific to the related domain provider.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With