Describe the bug/problem
I want to use "my.domain.com" to request the application at "127.0.0.1:8001", and use "my.domain.com/a" to request "127.0.0.1:8002". The first one works as I expected, but the second has a problem, Ideally, when visiting "my.domain.com/a" it will get "127.0.0.1:8002", In fact, it is "127.0.0.1:8002\a". Similar configurations are expected under nginx. here is my Caddyfile:
my.domain.com {
reverse_proxy / 127.0.0.1:8001
reverse_proxy /a 127.0.0.1:8083
}
and I also try this configuration:
my.domain.com {
reverse_proxy / 127.0.0.1:8001
handle /a/* {
uri strip_prefix /a
reverse_proxy 127.0.0.1:8083
}
}
and this
my.domain.com {
reverse_proxy / 127.0.0.1:8001
rewrite /a /
reverse_proxy /a 127.0.0.1:8083
}
my.domain.com {
reverse_proxy / 127.0.0.1:8001
route /a/* {
uri strip_prefix /a
reverse_proxy 127.0.0.1:8083
}
}
None of this will solve the problem.
Thanks for your question, and we're glad that you're using Caddy! This looks more like a question about how to use Caddy rather than a bug report or feature request. Since this issue tracker is reserved for actionable development items, I'm going to close this, but we have a community forum where more people will be exposed to your question, including people who may be more expert or experienced with the specific question you're facing. I hope you'll ask your question there, and thanks for understanding!
I think this is what you're looking for:
my.domain.com {
reverse_proxy 127.0.0.1:8001
handle_path /a* {
reverse_proxy 127.0.0.1:8083
}
}
handle_path is the same as handle plus uri strip_prefix.
Note that I'm doing /a* and not /a/*, because /a/* will not match /a because it's looking for that extra /.
Also, / will only match / and not /foo, so I think this is closer to what you actually want, by omitting /, which is the same as *, i.e. match any request.
But as @mholt said, please ask your usage questions on the forums next time :slightly_smiling_face:
thanks, it's worked. 馃槃
Most helpful comment
I think this is what you're looking for:
handle_pathis the same ashandleplusuri strip_prefix.Note that I'm doing
/a*and not/a/*, because/a/*will not match/abecause it's looking for that extra/.Also,
/will only match/and not/foo, so I think this is closer to what you actually want, by omitting/, which is the same as*, i.e. match any request.But as @mholt said, please ask your usage questions on the forums next time :slightly_smiling_face: