How to allow users to add their own custom domains?

I am using Next.js and I want to give my users the ability to add their own custom domains. For example, my app is hosted on DigitalOcean with domain ‘’ and the user, say John, page is ‘’ Now I want my user,John, to be able to add his own domain ‘’ so that it display ‘’ site.

I am new to networking so I am having trouble coming up with a viable solution.

Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.


What you could do is to add a catch-all Nginx server block or an Apache Vhost in case that you are using Apache.

  • For Nginx, it would look like this:
   server_name _;
  • For Apache you just create a virtual host without specifying ServerName

That way all unmapped domains will serve the content of this virtual host/server block.

After that, your clients would only have to add an A record to point to your Droplet’s IP address as per the instructions here:

If they wanted to use an SSL certificate, you could tell them that they could do this by using Cloudflare with their Flexible SSL certificate.

Then you can handle the rest of the logic on the application level.

I have done a similar thing with the DevBlog here, which allows people to have a blog with their own domain name:

Hope that this helps! Regards, Bobby