Header transform https -> http working.
Describe the bug
I have a YARP proxy https://example.com that is trying to proxy to a http backend service http://backend-service. When trying to add a header or remove a header with a transform it never applies the header transforms. This works fine for pathprefix transforms etc. When changing to a https backend service the transforms work fine. Is this a known limitation or a bug?
To Reproduce
builder.Services.AddReverseProxy()
.LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"))
.AddTransforms(builderContext =>
{
// Works fine
builderContext.AddPathPrefix("/testing");
// Does nothing
builderContext.AddRequestHeaderRemove("X-Vendor-Id");
builderContext.AddRequestHeader("X-Vendor-Id", "example");
// Does nothing
builderContext.RequestTransforms.Add(new RequestHeaderRemoveTransform("X-Vendor-Id"));
builderContext.AddRequestTransform(async context =>
{
// Does nothing
context.ProxyRequest.Headers.Remove("X-Vendor-Id");
// Does nothing
context.HttpContext.Request.Headers.Remove("X-Vendor-Id");
});
});
Further technical details
Version 1.1.1
The issue is that the backend service was responding with a https redirect and yarp doesn't run the transform on subsequent requests.
YARP doesn't even follow redirects by default, did you enable that? Most redirects should be forwarded back to the client. In this case since the destination requires https you should start with that to avoid the redirect.
@Tratcher You are correct. It's my mistake the client is getting the raw redirect and following that and sending the unwanted header to the server. Thanks for the reply.