By powimujube
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 ‘https://app.com’ and the user, say John, page is ‘https://app.com/john’ Now I want my user,John, to be able to add his own domain ‘www.john.com’ so that it display ‘https://app.com/john’ site.
I am new to networking so I am having trouble coming up with a viable solution.
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!
Hello,
What you could do is to add a catch-all Nginx server block or an Apache Vhost in case that you are using Apache.
server_name _;
ServerNameThat 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:
https://docs.digitalocean.com/products/networking/dns/how-to/manage-records/
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
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.