IIS反向代理出站规则

问题描述 投票:0回答:1

我正在尝试设置反向代理,该代理已在Linux中使用nginx实现。我正在使用URL重定向插件和ARR。我想做的是有人点击[

www.example.com/product1/ 

它应该将请求发送到

product1.example.com:8443. 

如果有人击中

www.example.com/product2/ 

它应该将请求发送给product2.example.com:8449,依此类推。我面临的问题是,当使用product1.example.com:8443到达请求www.example.com/product1/并打开内容页面时,每当我尝试使用product1.example.com:8443访问www.example.com/product1/的内容时,都会出现错误404.0-Not Found,请请注意,product1.example.com:8443product2.example.com:8449不在IIS上托管。这些位于不同的VM上。我只是使用IIS反向代理来重写URL。我的理解是,这是任何相对路径,或者绝对路径也需要转换为新的URL结构。

原始web,conf文件如下:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="^product1(.*)" />
<action type="Rewrite" url="product1.example.com:8443/{R:1}" />
</rule>
<rule name="Portainer-reverse-proxy" stopProcessing="true">
<match url="^product2(.*)" />
<action type="Rewrite" url="://product2.example.com:8449/{R:1}" />
</rule>
</rules>
<outboundRules>
<rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
<match filterByTags="A, Form, Img" pattern="^/(.*)" />
<action type="Rewrite" value="/{C:1}/{R:1}" />
<conditions>
<add input="{URL}" pattern="^(product1|product2).*" />
</conditions>
</rule>
<preConditions>
<preCondition name="ResponseIsHtml1">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
</system.webServer>
</configuration>
xml iis reverse-proxy
1个回答
0
投票

您的重写URL不正确,您可以尝试以下代码:

<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="^product1(.*)" />
<action type="Rewrite" url="http://product1.example.com:8443{R:1}" />
</rule>
<rule name="Portainer-reverse-proxy" stopProcessing="true">
<match url="^product2(.*)" />
<action type="Rewrite" url="http://product2.example.com:8449{R:1}" />
</rule>

最诚挚的问候,

山姆

© www.soinside.com 2019 - 2024. All rights reserved.