IIS Rewrite 在重写到外部网站时始终返回 502 bad gateway

问题描述 投票:0回答:1

是一个部署在IIS上的小网站。我正在使用此网站上的重写功能来重写对外部网站的 http 请求。这是 web.config 中的重写设置。

<system.webServer>
        <rewrite>
            <rules>
                <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Rewrite" url="https://about.gitlab.com/" logRewrittenUrl="true" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>

它总是返回

HTTP Error 502.2 - Bad Gateway

HTTP 错误 502.2 - 网关错误 尝试路由请求时出现连接错误。

如果我只是使用指向此网站内页面的内部路径,使用相对路径,以

/
开头,那么它就可以正常工作。改成外部网站后,总是返回
HTTP Error 502.2 - Bad Gateway

有什么地方需要更新吗?

asp.net iis url-rewriting
1个回答
0
投票

这是我解决问题的方法。它可能不是所有

502 bad gateway
问题的解决方案,但它解决了我的问题。

在应用程序请求路由 -> 缓存设置 -> 内存缓存持续时间中。我把他的值设置为0。然后它就按预期工作了。

© www.soinside.com 2019 - 2024. All rights reserved.