我有多个服务运行在服务器上的域abc.com和我的web应用程序在不同的服务器xyz.com上运行。我有一个需求,我需要这样写urlrewrite,如果我输入
- xyz.com/service1→如果我输入 ,它应该调用运行在abc.com:1234上的service1。
- xyz.com/service2→它应该调用/redirect到运行在abc.com上的service2:5678等等。
如何为它重写url ?
我正在使用IIS版本10窗口服务器2022
您可以尝试使用反向代理,以下情况您可以作为参考:
<rewrite>
<rules>
<rule name="Reverse Proxy to service1" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{SERVER_PORT}" pattern="1234" />
</conditions>
<action type="Rewrite" url="http://x.com/service1" />
</rule>
<rule name="Reverse Proxy to service2" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{SERVER_PORT}" pattern="5678" />
</conditions>
<action type="Rewrite" url="http://x.com/service2" />
</rule>
</rules>
</rewrite>
更多信息可以参考这个链接:反向代理与URL重写v2和应用请求路由