【发布时间】:2020-08-04 20:04:41
【问题描述】:
在托管在 Azure 应用服务中的 DNN 站点上,我们在 web.config 中设置了以下自定义规则:
<rewrite>
<rules>
<rule name="Proxy" stopProcessing="true">
<match url="^base3/?(.*)" />
<action type="Rewrite" url="https://(a website hosted in aws s3)/tx/{R:1}" />
<serverVariables>
<set name="HTTP_ACCEPT_ENCODING" value="" />
<set name="HTTP_X_ORIGINAL_HOST" value="{HTTP_HOST}" />
<set name="HTTP_X_Blog" value="1" />
</serverVariables>
</rule>
</rules>
我们还在applicationHost.xdt中设置了以下内容
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.webServer>
<proxy xdt:Transform="InsertIfMissing" enabled="true" preserveHostHeader="false" reverseRewriteHostInResponseHeaders="false" />
<rewrite>
<allowedServerVariables>
<add name="HTTP_X_ORIGINAL_HOST" xdt:Transform="Insert" xdt:Locator="Match(name)"/>
<add name="HTTP_X_UNPROXIED_URL" xdt:Transform="Insert" xdt:Locator="Match(name)"/>
<add name="HTTP_ACCEPT_ENCODING" xdt:Transform="Insert" xdt:Locator="Match(name)"/>
<add name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" xdt:Transform="Insert" xdt:Locator="Match(name)"/>
<add name="HTTP_X_Mischief" xdt:Transform="Insert" xdt:Locator="Match(name)"/>
<add name="HTTP_X_Blog" xdt:Transform="Insert" xdt:Locator="Match(name)"/>
</allowedServerVariables>
</rewrite>
</system.webServer>
</configuration>
但是,当尝试导航到它 (https://(ourazure webapp.com)/base3/index.html) 时,我们不断收到错误 您要查找的资源已被删除,名称已更改,或暂时不可用。这令人困惑,因为这是我们在其他网站上使用的重写规则。
我们甚至在新的应用服务上尝试了相同的方法,上面的重写规则运行良好..
试图通过启发式分析找出问题所在,在我们的 web.config 上,重写规则现在在以下情况下有效:
在<system.webServer>
<modules runAllManagedModulesForAllRequests="true">下
然后评论<add name="UrlRewrite" type="DotNetNuke.HttpModules.UrlRewriteModule, DotNetNuke.HttpModules" preCondition="managedHandler" />
但是,主站点现在中断了..
我们如何实现适用于DotNetNuke.HttpModules.UrlRewriteModule, DotNetNuke.HttpModules 的重写规则?
【问题讨论】:
-
可以先尝试部署在本地IIS上,安装好url重写模块后,看看是否生效,保证程序正确。
-
嗨@Jason,听从了你的建议,是的,重写工作正常。此重写也在另一个 azure app 服务中设置。你对处理这个问题有什么建议?
-
我还发现 url 重写在 azure 中不起作用。也许你可以使用应用网关来设置url重写的规则。^_^
标签: azure-web-app-service dotnetnuke