How does workdpress.com achieve this, where everyone, get a subdomain, like chooseName.wordpress.com after a new user sign up and when the subdomain has not been chosen?
-
2What is your question as the title and content seem to be asking different questions? Based on the title, this may answer your question https://serverfault.com/questions/652237/whats-the-maximum-number-of-ips-a-dns-a-record-can-have – Keith Langmead Jun 23 '23 at 05:59
2 Answers
I believe they have a wildcard CNAME record:
*.wordpress.com. CNAME lb.wordpress.com.
So any query to the name which doesn't exists explicitly gets answered with this CNAME record.
This seems plausible because you can just generate random valid DNS name ending with wordpress.com, which is unlikely to be taken by anyone, and yet the DNS answers with this CNAME. So (almost) all hostnames like *.wordpress.com were set pointing to the lb.wordpress.com a priori, and they work at the DNS level even when not claimed.
How do they process it is another question. Basically, the web servers behind lb.wordpress.com
just use the Host
header as additional input parameter. After someone claims some name, it is added to some database table which gets queried with this parameter.

- 10,947
- 2
- 24
- 45
-
can you provide more detail on how to achieve that ? maybe some keywords for google search or some guides to read on? – user294265 Jun 23 '23 at 06:27
-
What "this"? DNS? Just create such a record and it will work. How to write such a web application? First learn how to write a decent *ordinary* web application without these fancy tricks, and while you'll be learning it, the answer will eventually become apparent once you gain enough knowledge on various diverse subjects. Otherwise the question is too broad to be answered here and I believe such a "how to" could not exist, and even it does it must be hopelessly useless (too generic or too long). Also, learning material recommendations are off topic on ServerFault. – Nikita Kipriyanov Jun 23 '23 at 06:32
-
The key idea (what's different in comparison to "ordinary" web application) I already mentioned: you have to use the `Host` header as an additional parameter in an application. – Nikita Kipriyanov Jun 23 '23 at 06:37
Too long for a comment, but indeed as already answered (please vote up)
1. a wildcard DNS *.wordpress.com.
record so that you don't need to actually create a new DNS record, a new subdomain, for each new subscriber.
2. A similar pre-installed wildcard SSL certificate valid for *.wordpress.com.
so that all potential subdomains automatically already have TLS support and there is no need to generate and install a new SSL certificate for each new subscriber either.
3. A web site / web application that is designed for multi tenancy. For each new subscriber only a new profile gets created and their "own" customised WordPress site becomes active immediately, without having to install, deploy, configure and customise a copy (or an instance) of the (stand alone) web application.
This leverages the fact that for HTTP/HTTPS the web browser must send a Host:
header with each request containing the DNS hostname of the website the visitor wants to visit. That allows the server back-end to select if a subscriber using that subdomain exists and then show the pages for that particular WordPress site.
When visiting a subdomain which hasn't been claimed yet by a subscriber, the server backend will typically take you to a sign-up page.
(For background see the name based virtual hosting and for TLS the Server Name Indication wikipedia articles.)

- 77,029
- 24
- 135
- 201