【问题标题】:IIS Rewrite and reverse proxy for multiple applications多个应用程序的 IIS 重写和反向代理
【发布时间】:2019-03-12 16:25:42
【问题描述】:

我有一个 IIS 10,上面配置了一个网站。该网站下方有多个应用程序。 我的网站/app1 - 我的网站/app2 - 我的网站/app3

我有另一台服务器(我们称之为 EndServer)在 3 个不同的端口上托管 3 个网站。

好吧,现在我想做的是使用 IIS 作为反向代理,将应用程序 1 重定向和屏蔽到第二台服务器中的这些网站之一,并将应用程序 2 重定向到另一个服务器。 最后,用户输入https://mywebsite/app1,就会在Endserver中看到网站1的内容。

注意:对我来说,最终用户看到的 URL 像 https://mywebsite/app1/ 这样很重要

我应该如何编辑下面的规则:

<rewrite>
        <rules>
            <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                <match url="(.*)" />
                <action type="Rewrite" url="http://endserver:8052/{R:1}" />
                <conditions trackAllCaptures="true">    
                </conditions>
           </rule>
  </rewrite>

谢谢 A.

【问题讨论】:

标签: url iis proxy url-rewriting reverse-proxy


【解决方案1】:

根据你的描述,我建议你可以尝试使用下面的url重写规则。

<rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions trackAllCaptures="true">
                        <add input="{URL}" pattern="^/app1/(.*)" />
                    </conditions>
                    <action type="Rewrite" url="http://endserver:8052/{C:1}" />
                </rule>
 <rule name="ReverseProxyInboundRule2" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions trackAllCaptures="true">
                        <add input="{URL}" pattern="^/app2/(.*)" />
                    </conditions>
                    <action type="Rewrite" url="http://endserver:8053/{C:1}" />

                </rule>

【讨论】:

    【解决方案2】:

    感谢您的回答。 我得到了同样的错误。如下所示 /App1 在 localhost:Port 之后的 URL 中丢失 localhost:8888/assets/styles/Custom.css?m=1549903616.0

    我认为问题在于重写响应 URL。我不知道我可以在 URL 中添加缺少的部分。

    问候。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-30
      • 2016-01-28
      • 2020-09-05
      • 2020-09-05
      相关资源
      最近更新 更多