Yeah, [ ]
are arrays in JSON, and allow you to have multiple entries with guaranteed order, so if you only have one item, you need to reference the 0th item when traversing. For objects, i.e. { }
, each member has a string key, so you use those to traverse instead of a numerical index. Objects do not have guaranteed order.
Think of JSON like an upside-town tree, or node graph. Each /
in the URL is going one level deeper into this tree, following a branch.
You can also run caddy adapt --pretty
on your Caddyfile. Always the fastest way to learn what a working/correct JSON might look like for a feature you don’t quite understand yet.
Not if the array is empty. That depends on what you configured.
Yeah, higher numbers will be the subsequent routes in the routes
array. For example, say it looked like "routes": [ <first>, <second>, <third> ]
, then those route entries would be accessed as 0, 1, and 2 respectively. If it looked like "routes": []
then there’s no entries, and accessing 0 would fail and return an error because there’s nothing there to access. you’d need to push something into routes
for 0 to get the first item in the array, cause otherwise there’s no item for 0 to reach.
So, what exactly are you trying to achieve? What exactly are you trying to add to your config, and when?
I haven’t totally dug into your above posts to try and assume what it is you’re trying to do, but if you’re trying to add a new route when a customer is adding their own domain, then you might want to consider using On-Demand TLS instead, which would let you avoid changing Caddy’s config altogether. But I might be wrong and that might not be your goal.