Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

martiros's avatar

Custom-domains for multi-tenant SaaS application with automatic SSL

Hi all, I am working on jBoard, which allows customers to create their own job board without any code and link to a custom domain. When they enter their own domain (and, of course, configure the DNS records), our server should open their job board with HTTPS enabled by default.

While I have the Laravel code in place for handling custom domain routing, I am not sure what solution to pick on the server-side for automatically generating SSL certificates.

Looks like CaddyServer already has a solution for On-Demand SSL generation and also has a plugin for storing the generated certificates in Redis (so when load balancing, each server will not have to request a certificate again but will get it from Redis if the certificate already been generated).

But to do this I need to replace Nginx with Caddy, which I am not sure is a good idea.

I wonder if there are other solutions that you can recommend or maybe someone already worked with Caddy-On Demand SSL and can share their experience?

0 likes
8 replies
fideloper's avatar
Level 11

Caddy is a very capable web server, I wouldn't worry too much about replacing Caddy with Nginx.

I don't have first hand experience but I know others who have it in production for fairly large systems.

Another thing you can do is use Nginx and have some automation create SSL certificates for you via certbot/lets encrypt automatically.

However, Caddy will handle quite a few things better - I believe it can use DynamoDB (or something similar) as a place to store certificate files so you can centralize the location of where ssl certificates are stored (useless if you ever need to load balancer your application across several web servers).

1 like
martiros's avatar

thank you, will go forward with caddy

viedev's avatar

@fideloper is right about Caddy, that's what I'd recommend too.

I know this is an older post but I suspect a lot of people end up here when they try to sort out custom domains in Laravel, so I figured it's worth coming back with some real world data. I can say, with experience*, that Caddy can very likely handle whatever scale you have, across distributed servers or a single server.

It might take a bit of learning and time, but in my opinion there's no open source server/cert manager out there that I think could do a better job at automating this than Caddy.

These are the things you'll likely need to spend a bit of time sorting out:

  • exactly what you want your config to look like (just subdomains or apex domains too? custom headers? etc.)
  • how you want to update (push or pull? on change or batched?)
  • how you want to monitor it (things happen, issues mean custom domains are down)
  • have a process for when things don't go right (certs get revoked by CAs, CA ratelimits, etc.).
    • Caddy goes a long way helping you here but if you have much scale at all, you'll likely run into these things sooner than later.

* Source:

I'm the founder and developer of https://approximated.app, which is a managed service to handle custom domains for those that don't want to build or maintain this themselves. It reliably serves hundreds of thousands of domains, millions of requests per month, and terabytes of traffic, and part of what we use is a customised version of Caddy under the hood.

Anyone who's looking to add custom domains to their Laravel app, I've also put up an example Laravel app repo where you can see some examples of how to handle the routing/middleware/etc. for custom domains.

martinbean's avatar

Nothing like backlinks disguised as a question…

martiros's avatar

@martinbean juat because my question contained a link to the product, doesn't mean that the question wasn't real. Anyhow I removed the link that you are referring to

1 like
martiros's avatar

And to add to my point above, I searched the forum for similar questions and posted my question only after making sure no one asked the same question before

1 like
hayk.martirosyan's avatar

I would not worry about caddy, we are using now Caddy on production and it handles high load very well.

1 like

Please or to participate in this conversation.