Organizing Sites into multiple json files


I looked around to find a simple solution to do as in the topic: Organizing Sites into multiple Caddyfiles
But instead of doing with caddyfile in json.
Here is my caddy.service file:

# caddy.service
# For using Caddy with a config file.
# Make sure the ExecStart and ExecReload commands are correct
# for your installation.
# See for instructions.
# WARNING: This service does not use the --resume flag, so if you
# use the API to make changes, they will be overwritten by the
# Caddyfile next time the service is restarted. If you intend to
# use Caddy's API to configure it, add the --resume flag to the
# `caddy run` command or use the caddy-api.service file instead.


ExecStart=PATH/CADDY/2.4.0/caddy run --environ --config /etc/caddy/*.json
ExecReload=PATH/CADDY/2.4.0/caddy reload --config /etc/caddy/*.json


Thanks for helping out :wink:

It’s not possible to run Caddy with multiple JSON configs. Merging configs is out of scope.

Either use Caddyfiles, or merge the JSON configs yourself before running Caddy.

1 Like

It’s a shame not to offer it …

Is it possible to switch from json to Caddyfile?
Because I have my config in json

Thank you

No. The Caddyfile is a one-way conversion. It isn’t a one to one mapping, the Caddyfile does a bunch of magic to make writing configuration simpler. Undoing that isn’t possible.

Also, I’d just like to mention regarding multiple JSON files – consider git; there, merging still requires user interaction, because merging is ambiguous. There’s no way to reliably merge multiple configs automatically without risk. So it’s up to you to do it yourself before passing it to Caddy.

1 Like

Ok thanks for the support

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