Here’re 2 websites with their own Caddyfile
Expected working behaviors
expect site-a working, YES, it’s working fine (first one to start)
expect site-b working, without affect site-a
but it’s NOT working. (caddy DOES NOT working in this way)
what currently HAVE TO be done is – merging this 2 Caddyfiles into one and start with it.
if you want to stop site-a, you HAVE TO remove the site-a part off the merged Caddyfile and reload. why NOT just run
caddy stop under the directory /here/site-a/?
It will be great if caddy works in this way:
start/stop only using current directory’s Caddyfile, without affect another one (started under another directory with a different Caddyfile).
(btw: it’s mess to manage multiple websites’ config in one file. nginx is providing a including method to seperate site’s config into a single config file)
Like I said on Github – that’s impossible because of the way Caddy was designed. It would require a full rewrite of the underlying configuration management to support this kind of functionality. And there’s just no appetite for that.
Are you aware you can use
import to pull in contents from another file, from your main Caddyfile?
You could also run multiple Caddy instances, one per site, with each one using a dedicated port, e.g.
8001 for site A,
8002 for site B, etc, then run a main Caddy instance which binds to the standard ports 80 and 443 for HTTP and HTTPS, and
reverse_proxy to your other sites.
But that approach is way more complicated, and frankly, overkill.
I don’t understand why you feel you need to do it this way though. What’s wrong with keeping all your sites running from one config? Every other user does it, and they seem to be happy with it.
FYI, you posted this in the wrong category. It should be in the Help category. And since you chose the wrong category, you weren’t presented with the help topic template. Please fill that out.
Show us what your config actually looks like. What are the specific pain points? It really feels like the XY problem - Wikipedia.