简体   繁体   English

YARP - 如何修改子应用程序路径?

[英]YARP - How to modify subapplication path?

My Scenario我的情景

I have the following IIS site:我有以下 IIS 站点:

www.site.com www.site.com

Calling www.site.com/Login redirects correctly to the page in my subapplication, the browser bar shows www.site.com/Login .调用www.site.com/Login会正确重定向到我的子应用程序中的页面,浏览器栏显示www.site.com/Login

But, calling www.site.com , redirects to www.site.com/subapplication/Login , it also works, but I want www.site.com to show www.site.com/Login in the browser bar.但是,调用www.site.com ,重定向到www.site.com/subapplication/Login ,它也可以工作,但我希望www.site.com在浏览器栏中显示www.site.com/Login

IIS Structure IIS结构

www.site.com is a .NET Core site with YARP www.site.com是带有 YARP 的 .NET 核心站点

www.site.com/subapplication/Login is a .NET Framework site www.site.com/subapplication/Login是一个 .NET 框架站点

appsettings.json appsettings.json

  "ReverseProxy": {
    "Routes": {
      "fallbackRoute": {
        "ClusterId": "fallbackCluster",
        "Order": "1",
        "Match": {
          "Path": "{**catch-all}"
        },
        "Transforms": [
          { "PathRemovePrefix": "/web" }
          { "RequestHeaderOriginalHost": "true" }
        ]
      }
    },
    "Clusters": {
      "fallbackCluster": {
        "Destinations": {
          "fallbackApp": {
            "Address": "https://dansaleswebdev.danone.com.br/dev/web/"
          }
        }
      }
    }
  }

What I want我想要的是

www.site.com redirect to www.site.com/Login instead of www.site.com/subapplication/Login www.site.com重定向到www.site.com/Login而不是www.site.com/subapplication/Login

I already tried to add the PathRemovePrefix transformation to remove /subapplication but it not worked.我已经尝试添加PathRemovePrefix 转换以删除 /subapplication 但它不起作用。

Answered by Tratcher on GitHub . TratcherGitHub上回答。

See #1548 .#1548

You either need to change the framework app to generate the public urls, or you need to re-write the location header on the response.您要么需要更改框架应用程序以生成公共 url,要么需要在响应上重新写入位置 header。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM