Load valid URL from DB

Hi, I’m using Caddy as a proxy to send the requests to the applications and it’s working great! Now, I will have a lot of webpages and domains in the server, all of them are created dynamically so, I can’t be editing the caddyfile everytime that a domain/subdomain is registered. I work with Golang applications running in differents ports and I only redirect to the right one. So, my question is: is there a way in Caddy to load the URL and confidurations (directives) of everysite from a database? or how can I do that with Caddy?
Thank you!

Have you tried looking at it another way?

What you want can also be solved with autogenerating the Caddyfile with data from a database and reloading Caddy.

That way you don’t rely on Caddy doing anything special.

No, currently there is not. The standard approach to achieve something similar is to generate a configuration file automatically from your external source and then reload the configuration every time it is changed.

Until Caddy gets an API, perhaps the best thing to do would be to have a “master” Caddyfile that you load Caddy with that contains import sites/* and then you just plop new Caddyfiles into that folder, and signal Caddy with USR1 to reload when you add or remove a site.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.