I was wondering if someone could provide me with or point me to an example of a Caddy JSON config file for serving a WordPress (static install without Docker) site. I found this tutorial (Setting up WordPress with Caddy on Ubuntu) and some others, but they all use the Caddyfile format, which I find quite challenging to convert to a JSON config.
I read somewhere that JSON configs are the preferable way to set up Caddy, but almost all examples are written in Caddyfile. Also, I’m aware of this page (JSON Config Structure - Caddy Documentation), but I find it quite overwhelming to do a specific configuration.
There’s no need to wait for someone to provide a JSON example. Caddy itself can do this for you - with any Caddyfile.
Check out caddy adapt, the command line option that takes a Caddyfile and prints out exactly what it would adapt it to as JSON internally.
I recommend this approach for anyone already familiar with the Caddyfile that wants to learn the JSON configuration - adapt a few simple Caddyfiles, and a few complex ones, and see how the JSON changes based on the different Caddyfile config.
It’s really not. Caddyfile is much preferred, especially for beginners.
In early versions Caddyfile support wasn’t fully complete, so certain things were only possible via JSON config. At this point, it’s probably more like 99.5% coverage.
Using JSON config is mainly if you’re going to want to do scripted config changes (writing a program to manipulate and push config changes to Caddy). But if you’re just serving a simple app without dynamic changes needed, then Caddyfile is the way to go.
@francislavoie Got it, thanks for the clarification! I do need it for scripted configuration since I’m building a multi-tenant platform, so I might have interpreted it that way.
Are you sure you need to reconfigure Caddy though? There’s many ways to have a single static config that has dynamic behaviour. You can use On-Demand TLS if your customers will be pointing custom domains to your server, or dynamic upstreams for the reverse_proxy if you have separate servers per tenant (and need to choose the upstream based on the request in whatever way).