【问题标题】:How to Redirect or Forward URLs of a application running on a Virtual machine to Another Virtual machine如何将虚拟机上运行的应用程序的 URL 重定向或转发到另一台虚拟机
【发布时间】:2022-11-18 14:17:36
【问题描述】:

我有多个应用程序 URL 在名为 testCM 的机器上运行 应用程序 1 在 https://testVM:4000 上运行 应用程序 2 在 https://testVM:5000 上运行 就像这些在不同端口上运行的众多应用程序一样。

现在我已经设置了一个新的虚拟机 (newTestVM) 并将在旧 VM(测试 VM)上运行的所有应用程序迁移到新虚拟机。

现在 应用程序 1 也在 https://newTestVM:4000 上运行 应用程序 2 在 https://newTestVM:5000 上运行 像这样,其他应用程序在不同的端口上运行。

我现在面临的问题是,我不希望用户再使用我的旧(testVM),我对旧 VM 发出的所有请求都应该重定向到新 VM(newTestVM)。我将如何做到这一点?

要求 -> 如果用户输入 https://testVM:4000 它应该将我重定向到 https://newTestVM:4000

我可以使用 IIS 执行此操作吗?有 HTTP 重定向或任何其他方式

【问题讨论】:

    标签: http redirect iis https virtual-machine


    【解决方案1】:

    根据您的描述,我了解到您希望如果用户输入 https://testVM:4000,它应该重定向到 https://newTestVM:4000。

    您只需使用 URL 重写模块添加规则。像下面这样。

    <system.webServer>
       <rewrite>
              <rules>
                     <rule name="Redirect to newtestVM">
                           <match url="^(.*)$" />
                           <conditions>
                                  <add input="{HTTP_HOST}" pattern="^testVM:4000$" />
                           </conditions>
                           <action type="Redirect" url=http://newtestVM:4000/{R:1} />
                     </rule>
              </rules>
       </rewrite>
    </system.webServer>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-05
      • 2010-10-07
      • 2017-04-08
      • 1970-01-01
      • 2012-02-06
      • 2011-09-22
      • 1970-01-01
      相关资源
      最近更新 更多