IIS反向代理出站规则



我正在尝试设置反向代理,该代理已经在Linux中使用nginx实现。我在和ARR上使用URL重定向广告。我想做的是当有人点击时

www.example.com/product1/ 

它应该向发送请求

product1.example.com:8443. 

如果有人点击

www.example.com/product2/ 

它应该将请求发送到CCD_ 1等等。我面临的问题是,当请求使用www.example.com/product1/到达product1.example.com:8443并且内容页面打开时,每当我尝试使用www.example.com/product1/访问product1.example.com:8443的内容时,都会出现错误404.0-未找到,请注意,product1.example.com:8443product2.example.com:8449未托管在IIS上。这些位于不同的虚拟机上。我只是使用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="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>
</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>

您的重写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>

致问候,

Sam

最新更新