-
Notifications
You must be signed in to change notification settings - Fork 863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider having a configuration setting to allow YARP use raw target for the forwarded requests #2702
Comments
I think the underlying issue you're hitting is #1419. Re: workaround, you shouldn't need the transform/handler split, you can set the Uri in the transform directly. |
In the workaround I did try setting |
If you ensure that your transform is the last one in the list you have all the context, the Uri can be constructed in the transform like so: context.ProxyRequest.RequestUri = RequestUtilities.MakeDestinationAddress(context.DestinationPrefix, context.Path, context.Query.QueryString); followed by any modifications you wish to make. The code snippet is exactly the same thing that YARP would later do for you if Besides this case (escaped forward slash), did you see other problematic cases? |
Thanks for tip on request uri transform!
Well, in general, unescaping loses fidelity of forwarded requests. E.g. if a customer wanted to test how their server deals with escaping while using a dev tunnel to forward the requests, they'd want to get the request path as is, with all %xx unescaped. Arguably, it's a niche use case. |
There are some URL transformations YARP (or rather, The escaped slash bug is unfortunate, but it will hopefully be fixed at some point. If there are other problematic cases where YARP is modifying things unnecessarily we would of course want to look into that. If they come up we could consider adding options to control YARP behavior, but I'm not aware of any at the moment. For cases where you need absolute control over exactly what YARP sends out on the other side, we've exposed a |
Consider having a configuration setting to allow YARP use raw target for the forwarded request path, query and fragment.
When YARP runs as middleware in ASP.NET, it gets request path & query after they have been unescaped from the original raw target. This makes forwarded request path & query not matching the original ones. Escaping may be lost or different.
It was reported by codespaces in dev tunnels in microsoft/dev-tunnels#492
The following may be a workaround:
IHttpRequestFeature.RawTarget
property on the incoming request and saves it toProxyRequest.Options
like this:DelegatingHandler
to HTTP message handler chain that gets raw target fromrequest.Options
and updates theRequestUri
like this:SendAsync
useHttpMessageInvoker
with this handler.The text was updated successfully, but these errors were encountered: