【问题标题】:iis reverse proxy rule fail with the same virtual directoryiis 反向代理规则因相同的虚拟目录而失败
【发布时间】:2020-01-10 08:01:52
【问题描述】:

我有两个网址,

第一个看起来像:localhost1/api/test/2.0/aaa

第二个看起来像:localhost2/api/test/3.0/aaa

当使用 localhost1/api/test/3.0/aaa 时,我想重写为 localhost2/api/test/3.0/aaa。 我的重写地图:原始值为 localhost1,新值为 localhost2

我的入站规则是 api/(.+)/3.0/(.+),url 匹配是 https://{C:0}/api/{R:1}/3.0/{R:2}

当我使用 localhost1/api/test/3.0/aaa 我总是从 localhost1/api/test/2.0/aaa 得到响应,但我真正想要的是 localhost2/api/test/3.0/aaa 请告诉我如何解决它。

(ps:如果使用localhost1/api/test2/3.0/aaa,我可以从localhost2/api/test2/3.0/aaa得到正确的响应,但存在locahost1/api/test)

谢谢。

【问题讨论】:

    标签: iis reverse-proxy


    【解决方案1】:

    据我所知,C:0 将匹配条件模式而不是入站模式。此外,我发现您只是编写规则以匹配localhost1/api/test/3.0/aaa 而不是api/test/2.0/aaa

    如果你想让2.0也重写到localhost2,我建议你可以添加下面的url重写规则。

                <rule name="Teeee">
                    <match url="api/(.+)/2.0/(.+)" />
                    <action type="Rewrite" url="https://localhost2/api/{R:1}/2.0/{R:2}" />
                </rule>
    

    【讨论】:

    • 我只是想用3.0重写到另一个url。
    猜你喜欢
    • 2017-05-08
    • 1970-01-01
    • 1970-01-01
    • 2018-10-24
    • 1970-01-01
    • 2015-09-28
    • 1970-01-01
    • 2019-10-05
    • 1970-01-01
    相关资源
    最近更新 更多