microsoft / reverse-proxy

A toolkit for developing high-performance HTTP reverse proxy applications.
https://microsoft.github.io/reverse-proxy
MIT License
8.53k stars 839 forks source link

Path not working even if I use {**catch-all} #2618

Closed marenfis closed 4 weeks ago

marenfis commented 1 month ago

Describe the bug

I started exploring YARP using the documentation https://microsoft.github.io/reverse-proxy/articles/getting-started.html. If I try the url https://localhost/test, /prod or /hugo, everything works as expected while other paths like /igor or /tryout are not working

To Reproduce

Further technical details

MihaZupan commented 1 month ago

Can you share the YARP configuration you're using? What do you see from the logs - are the requests being rejected by the proxy or by the backend service?

marenfis commented 1 month ago

``Here is the config I'm using (appsettings.json):

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*",
  "ReverseProxy": {
    "Routes": {
      "route1": {
        "ClusterId": "cluster1",
        "Match": {
          "Path": "{**catch-all}"
        }
      }

    },
    "Clusters": {
      "cluster1": {
        "Destinations": {
          "destination1": {
            "Address": "https://example.com/"
          }
        }
      }
    }
  }
}

And the log I got:

info: Yarp.ReverseProxy.Forwarder.HttpForwarder[9]
      Proxying to https://example.com/igor HTTP/2 RequestVersionOrLower
info: Yarp.ReverseProxy.Forwarder.HttpForwarder[56]
      Received HTTP/1.1 response 500.
MihaZupan commented 1 month ago

What behavior were you expecting? It seems like you've asked YARP to proxy requests as-is, and the proxy returned whatever response example.com returned for that path.

marenfis commented 1 month ago

Seems I didn't understand how it works. I was expecting that the path is not included in the forwarded request:

https://localhost/test is forwarded to https://example.com

instead, the request ist forwarded to https://example.com/test - of course.

Sorry for that stupid issue ...