Azure应用服务applicationHost.xdt似乎没有效果
我试图通过使用Azure网站设置反向代理,大致跟在this guide之后,它解释了如何在此类网站上修改ApplicationHost.config
- 但它不起作用为了我。Azure应用服务applicationHost.xdt似乎没有效果
我已经有这个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="InsertIfMissing" />
<add name="HTTP_X_UNPROXIED_URL" xdt:Transform="InsertIfMissing" />
<add name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" xdt:Transform="InsertIfMissing" />
<add name="HTTP_ACCEPT_ENCODING" xdt:Transform="InsertIfMissing" />
</allowedServerVariables>
</rewrite>
</system.webServer>
</configuration>
我把它放在site
目录我的web应用程序。
的变换似乎得到执行(从转换日志):
2017-09-06T12:12:20 StartSection Executing InsertIfMissing (transform line 8, 50)
2017-09-06T12:12:20 on /configuration/system.webServer/rewrite/allowedServerVariables/add
2017-09-06T12:12:20 Applying to 'allowedServerVariables' element (no source line info)
2017-09-06T12:12:20 EndSection Done executing InsertIfMissing
我确实有这些块中的四个。
我仍然得到500s设置与重写头。详细的错误信息包含:
<h3>HTTP Error 500.50 - URL Rewrite Module Error.</h3>
<h4>The server variable "HTTP_X_UNPROXIED_URL" is not allowed to be set. Add the server variable name to the allowed server variable list.</h4>
不知道该怎么做。有任何想法吗?
调查这些问题的关键是要确定问题是转换没有做正确的事情,还是applicationhost.config没有按预期工作。
您可以从Kudu控制台检查D:\local\Config
中生成的applicationhost.config。
有关详情,请参阅this page。
我已经检查了几次,并发布applicationHost.xdt在我的主插槽上工作,但没有转换发生在我的开发插槽。 xdt是一样的,我将它放在相同的位置,但即使重新启动应用程序后也没有创建转换日志文件夹。我得到的500是访问被拒绝,试图访问我的web.config的URL Rewrite规则中的标题。我在想,如果这是一个鸡和蛋的事情,变形不会发生,因为它发生在管道后面比URL重写评估? – Sentinel
@Sentinel会提出一个新问题,因为你的案例看起来更具体。随意从这里链接到它。 –
你好[大卫Ebbo](https://*.com/users/111888/david-ebbo) - 你偶然有任何解决方案[重写规则到IIS的HTTPS重定向到HTTP导致null HttpContext.Request.ContentType ](https://*.com/questions/48871977/rewrite-rule-to-iis-for-https-redirect-to-http-causes-null-httpcontext-request-c)? – ttugates
请从https://github.com/projectkudu/kudu/wiki/Azure-Site-Extensions#understanding-what-could-go-wrong-with-xdt-transforms开始,并确定您的问题是否存在第二桶或第三桶。 –
我已经掌握了该资源 - 谢谢。我不知道如何看到最终的'applicationhost.config'。 – John