1. My Caddy version (caddy version
):
v2.0.0-rc.3 h1:z2H/QnaRscip6aZJxwTbghu3zhC88Vo8l/K57WUce4Q=
2. How I run Caddy:
a. System environment:
Ubuntu18.04
Caddy is run via systemd service unit.
d. My complete Caddyfile or JSON config:
{
"apps": {
"http": {
"servers": {
"srv0": {
"listen": [":443"],
"routes": [
{
"match": [
{
"host": ["localhost", "10.0.2.15"]
}
],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"encodings": {
"gzip": {}
},
"handler": "encode"
}
]
},
{
"handle": [
{
"handler": "rewrite",
"uri_substring": [
{
"find": "/test",
"replace": "",
"limit": 0
}
]
},
{
"handler": "reverse_proxy",
"upstreams": [
{
"dial": "localhost:4325"
}
]
}
],
"match": [
{
"path": [
"/test*"
]
}
]
},
{
"handle": [
{
"handler": "reverse_proxy",
"upstreams": [
{
"dial": "localhost:4321"
}
]
}
]
}
]
}
],
"terminal": true
}
]
}
}
}
}
}
3. The problem I’m having:
I’d like to have two reverse proxies set up - one which forwards requests made without any path (i.e. requests to /
) to localhost:4321
and one which forwards requests to /test*
to localhost:4325
. For the second proxy, I’d like to strip the /test
prefix from the URI when it is sent to the backend. I tried to use the rewrite
handler for this, but it does not work - the /test
prefix is being sent to the backend when the request is forwarded.
I’m probably making a mistake somewhere in the JSON config when setting this up so I would appreciate any guidance on how to do this correctly.
4. Error messages and/or full log output:
N/A
5. What I already tried:
Read relevant docs - as far as I can tell the config file should be correct.