I am trying to redirect all of the following api.aditya.diwakar.io/cot*, api.diwakar.io/cot* ā cot-reports.americas.diwakar.io/*. Essentially a simple domain change ignoring the /cot* prefix. The above configuration is what I believe should work, using handle_path that automatically would strip the prefix.
However, none of the URLs are getting matched with the handle_path, and instead are getting matched with the catch-all handle at the bottom of the api block. Running curl -iL https://api.aditya.diwakar.io/cot/disaggregated/067651 leads to:
HTTP/2 200
server: Caddy
content-length: 58
date: Sun, 12 Dec 2021 07:24:50 GMT
api matched api.aditya.diwakar.io/cot/disaggregated/067651
4. Error messages and/or full log output:
No error messages, just incorrect behavior as mentioned in 3.
5. What I already tried:
Removing the second handle block in the handle @api block seems to fix the behavior and it correctly redirects to cot-reports.americas.diwakar.io/..., but it is not working with what I believe is the proper configuration. Of course, I am new to Caddy and could be making a silly mistake. Thanks!
Interesting. If you adapt your config to JSON, youāll see that your handle block gets sorted before the handle_path for some reason. That shouldnāt happen. Thereās a bug in there somewhere. Iāll have to investigate later.
As a workaround, you can probably use route @api instead for the wrapping one, if you donāt need mutual exclusivity/fallback for the outer part.
Thanks @francislavoie for the response! I do unfortunately need a fallback on the outer subdomain. Do you know of any other workarounds in the meanwhile?