【问题标题】:IIS 10 rewrite to internal port for both http and httpsIIS 10 重写为 http 和 https 的内部端口
【发布时间】:2025-11-28 03:05:02
【问题描述】:

我有一个节点 js 应用程序在我的 Windows 服务器的端口 8080 上运行,并且可以通过 http://localhost:8080 从服务器内部访问。我想使用像app.mydomain.com 这样的子域,而不使用服务器外部的端口号来打开这个node.js 应用程序。我想完全将所有流量重写到这个端口,并且没有子目录的过滤器。

我已经在我的 IIS 上安装了 ARRv3_0urlrewrite2 并且还重新启动了服务器。还在服务器上安装了证书并分配给了这个 IIS 网站。目前,我将此文件用作我的web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Reverse Proxy to node server" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Rewrite" url="http://localhost:8080/{R:1}" />
                </rule>              
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

另外,我也在网站目录下创建了一个index.html文件,但是没有区别。

当我同时使用 httphttps 打开域时,我得到 404。

【问题讨论】:

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


【解决方案1】:

您需要注意一些提示。

  1. 您需要在 ARR 中勾选启用代理。 ARR->服务器代理设置->启用代理。
  2. 根据你的代理规则,当你从一个URL代理到另一个时,只重写了域,所以你必须确保URL中有页面信息,例如http://initialURL/index.html ,这将是对 http://localhost:8080/index.html 的最后一次重写。如果不想添加 index.html,可以启用默认文档并将 index.html 移动到第一个。

【讨论】:

  • 嘿,谢谢。 1号解决了我的问题。只是因为任何人都有这个问题:您应该首先从iis.net/downloads/microsoft/application-request-routing 安装 ARR。然后从 IIS 左侧边栏中选择您的服务器名称,然后打开 Application Request Routing Cache。如上面的截图,只需启用第一个复选框。
最近更新 更多