I have created my base configuration using Caddyfile. For production I will convert the file to json as I will be managing the config file via the the rest api. In this snippet I have a route that uses a map to do the reverse proxy.
{
"match": [{ "host": ["*.foundryserver.ca"] }],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"destinations": ["{backend_ip}"],
"handler": "map",
"mappings": [{ "input": "example.foundryserver.ca", "outputs": ["192.168.255.200"] }],
"source": "{http.request.host}"
},
{
"handler": "reverse_proxy",
"stream_close_delay": 28800000000000,
"upstreams": [{ "dial": "{http.request.host}:8080" }, { "dial": "{backend_ip}:30000" }]
}
]
}
]
}
],
"terminal": true
}
Can I put a @id on the match and the handle? Like so
@somematch {
"match": [{ "host": ["*.foundryserver.ca"] }],
"handle": [
{
"handler": "subroute",
"routes": [
@somehandle {
"handle": [
{
"destinations": ["{backend_ip}"],
"handler": "map",
"mappings": [{ "input": "example.foundryserver.ca", "outputs": ["192.168.255.200"] }],
"source": "{http.request.host}"
},
{
"handler": "reverse_proxy",
"stream_close_delay": 28800000000000,
"upstreams": [{ "dial": "{http.request.host}:8080" }, { "dial": "{backend_ip}:30000" }]
}
]
}
]
}
],
"terminal": true
}
then to reference the path via the rest api I would do something like:
curl -X DELETE "http://localhost:2019/id/somematch/handle/routes/id/somehandle