Skip to content

[YARP] How to set up a reverse proxy for another full web server in a sub path? #2604

Answered by MihaZupan
AbdallahR99 asked this question in General
Discussion options

You must be logged in to vote

The backend server has to cooperate with a reverse proxy. For example, it should use relative paths in hrefs/redirects, or it should generate those paths by honoring headers like "X-Forwarded-Prefix".

If the backend service isn't cooperative / you can't control it, you then have to fix up any such responses.
The configuration file transforms don't currently support the sort of syntax you tried to use to generate dynamic header values.
You could achieve this sort of transformation from code though, e.g. something like

builder.Services.AddReverseProxy()
    .LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"))
    .AddTransforms(context =>
    {
        if (context.Route.RouteId ==

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by MihaZupan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants