0

I'm running an Azure Web App that's meant to accept XML Posts. When I post to the urls using cURL everything works, however, when using Apache Camel/HTTP the POST results in a 400 error. When I look at the log files, the only difference is cs-host field. For the cURL commands the value is just the domain (e.g. azurewebsites.net), however the Apache POST appends port 80 (e.g. azurewebsites.net:80). I added a rewrite rule that would strip the port from the call (rule details below), but the POST still results in 400 error. The closest related post I could find was here: Including Port number in HTTP HOST header causes Service Unavailable error but unfortunately it looks like it's related to Netscaler, not Azure Web App, and the resolution didn't provide any detailed guidance.. Thanks for any input!

Here's the rewrite rule:

<?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>
Chris
  • 1
  • 3
  • Can you enable Failed Request tracing for your web app and share the traces with me. FREB logs should be generated as you are getting a 400 error. Also I wanted to ask as to why you are using XDT Transform and not add this in the web.config? – Kaushal Kumar Panday Jul 27 '17 at 17:22
  • Thanks for the response @KaushalKumarPanday . I have FREB enabled, but the xml log entry for the 400 error is 7K lines long so probably shouldn't post the whole thing in here :) any part you in particular you're looking for? Regarding XDT vs web.config: Azure App Service doesn't come with URL rewrite package installed, so to get the package I loaded their IIS Manager site extension (https://github.com/shibayan/IISManager) which manages through XDT instead of web.config. I'm open to better approach of course – Chris Jul 28 '17 at 00:35

0 Answers0