Question

Implement a wildcard sub-domain just like the one on Vercel, Netlify, WordPress, Tumblr, and many others

I’m not sure if this is the right place to ask this, but

I am talking about when you create a new blog with Tumblr, you can create your domain *.tumblr.com, or when creating a deployment on Vercel or Netlify, you can have *.vercel.app or *.netlify.app

I get the gist that it’s maybe using a wildcard sub-domain, and some API since the user can create it through the app, but how do you build or what tools do you use to build something like that?

Or if you can point me out to where I can learn how to build something like that, I would be very grateful.

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there @meepomodeon,

This is a nice topic!

I actually recently built a similar thing for https://devdojo.com/devblog where users can get their own blogs based on their usernames, eg. username.devdojo.com.

What I did was:

  • First create a wildcard A record DNS entry for *.devdojo.com to point to my Droplet’s IP address.

  • Then I created a default Nginx server block that catches all of the subdomains, I did that by setting the server_name to: .devdojo.com;, note the dot before the domain name.

  • As I am using Cloudflare, I took advantage of the free SSL certificate that they offer to cover all of the subdomains so that the subdomains were also secure.

  • Then finally on an application-level I would check the domain and server the relevant content for each site.

Hope that this helps! Regards, Bobby