我正在运行一个旨在接受 XML 帖子的 Azure Web 应用程序。当我使用 cURL 发布到 url 时,一切正常,但是,当使用 Apache Camel/HTTP 时,POST 会导致 400 错误。当我查看日志文件时,唯一的区别是 cs-host 字段。对于 cURL 命令,该值只是域(例如 azurewebsites.net),但是 Apache POST 附加端口 80(例如 azurewebsites.net:80)。我添加了一个重写规则,该规则将从调用中删除端口(下面的规则详细信息),但 POST 仍然导致 400 错误。我能找到的最接近的相关帖子是:Include Port number in HTTP HOST header会导致Service Unavailable错误,但不幸的是,它看起来与Netscaler有关,而不是Azure Web App,并且该解决方案没有提供任何详细的指导。谢谢任何输入!
这是重写规则:
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<location path="domain" xdt:Locator="Match(path)">
<system.webServer>
<rewrite xdt:Transform="InsertBefore(/configuration/location[(@path='domain')]/system.webServer/*[1])">
<rules>
<rule name="domainrule1" stopProcessing="true">
<match url="domain.azurewebsites.net:80(.*)" />
<action type="Redirect" url="http://domain.azurewebsites.net/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</location>
<location path="~1domain" xdt:Locator="Match(path)">
<system.webServer>
<rewrite>
<rules>
<rule name="domainrule2" stopProcessing="true" xdt:Transform="Insert">
<match url="domain.azurewebsites.net:80(.*)" />
<action type="Redirect" url="http://domain.azurewebsites.net/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</location>
</configuration>