Issuing multiple SSL certificates for domains using RESTful API?


I am very new to Caddy. How to create multiple SSL certificates using REST API ? What we are planning to do is to use Caddy as a load balancer to serve hundred of domains via https, and reverse proxy requests to nginx server.

So basically I’m trying to figure out if i can automate issuing SSL certificates for domains using RESTful API with Caddy.

Your support is highly appreciated.

Do you control the domains?

If so, just add them to your Caddy config.

If not, use on-demand TLS. There’s a guide for this here:

Hello Matt

Thanks for your reply, for the first option, yes, we control the domains, we control the DNS of our domains, we will be pointing them to the server at which Caddy is running and we will use Caddy to manage certificates for domains as well.

How can we add a domain to Caddy config and setup its certificate using rest API call ?

I’ve checked API — Caddy Documentation, but could not find an example about creating the certificate and adding a domain.

It’s a config API, so use the endpoint you prefer to modify your configuration to add the domain to it, next to all the other ones. Probably a POST request to a host matcher.

My recommendation if you’re new to it: start with a simple Caddyfile with one or two domains (use Let’s Encrypt’s staging endpoint or even internal TLS certs to test), then adapt it to JSON and then it will become pretty clear/obvious where to put the domains :slight_smile:

Trying to clarify a tiny detail (sorry if you already knew all of that):

The Caddyfile is just one of multiple Config Adapters — Caddy Documentation, that all spit out json.

So “adapt it” is meant in a very literal sense.
As there is the caddy adapt cli command :innocent:

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.