Any specific reason for using the JSON format? It’s typically used by automation-heavy users, where config is updated with scripts and code, or to use advanced features that aren’t available in the Caddyfile.
Anyways, the first issue with your config is this (and all other instances like it):
When you have multiple objects within the array, they’re treated as or
condition. I believe you want an and
, so you’ll have to put them within a single object in a 1-item array.
The second issue is you’re using {project}
here, but there’s no such placeholder. You use {http.vars.project}
in the following handler, but you didn’t use the vars
handler to begin with which sets the placeholder value. Also, shorthand placeholders, such as {path}
, don’t exist in JSON format.
Now for the main issue, do your projects’ directories have index.html
files? Double check that after fixing the config.
nitpick: the term “redirect” has a specific meaning in our context, in which the server tells the client, “try at that other URL”; and the client creates a new request/connection to the new URL. The accurate term for your scenario is proxy
, in which the server acts as middle-person moving the data back-and-forth between client and upstream.