【发布时间】:2020-04-27 09:54:34
【问题描述】:
我正在尝试设置已经在 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/ 并打开内容页面时,每当我尝试使用www.example.com/product1/ 访问product1.example.com:8443 的内容时,它都会给我错误404.0 - 未找到,请请注意,product1.example.com:8443 和 product2.example.com:8449 未托管在 IIS 上。这些在不同的虚拟机上。我只是使用 IIS 反向代理来重写 URL。
我的理解是任何相对路径,或者就此而言,绝对路径也需要转换为新的 URL 结构。
原网页,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>
【问题讨论】:
标签: xml iis reverse-proxy