Question

Is it possible to setup SSL protected subdomains using the DigitalOcean API?

Posted September 2, 2021 88 views
Node.js

I am building an application that allows users to build out-static websites on a subdomain within my application. I am curious what the most scaleable way to go about this is.

Currently, I plan on using the DigitalOcean API’s domain endpoints to create new CNAME and A records for the user. but I am not sure how to also provide SSL solely through the API.

Techstack: Next.js, Vercel, Node, DigitalOcean, NGINX, MongoDB

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.

×
Submit an Answer
1 answer

Hi there @alexdc2,

I don’t think that this could be achieved via the API. The DigitalOcean managed SSL certificates, are primarily used for managed services like load balancers and Spaces.

In your case, you could have a different automation system on your server itself that triggers a Let’s Encrypt validation process once your DNS records are in place.

You could use the certbot command-line tool to do that. And you could build this into your application creation process right after the DNS creation step.

You could follow the steps on how to use certbot here:

https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-20-04

Alternatively, you could issue a single wildcard SSL certificate for your main domain name and it would cover all of the possible subdomains (eg *.yourdomain.com), that way you would not have to issue separate SSL certificates for each subdomain. You could follow the steps here on how to set that up:

https://www.digitalocean.com/community/tutorials/how-to-create-let-s-encrypt-wildcard-certificates-with-certbot

Hope that this helps!

Regards,
Bobby

by Brian Boucheron
Let's Encrypt is a Certificate Authority (CA) that provides an easy way to obtain and install free TLS/SSL certificates, thereby enabling encrypted HTTPS on web servers. It simplifies the process by providing a software client, Certbot, that attempts to automate most (if not all) of the required steps. In this tutorial, you will use Certbot to obtain a free SSL certificate for Nginx on Ubuntu 20.04, and set up your certificate to renew automatically.