My ARR URL Rewrite works for all simple url:s as
/api/Login
,
/api/BusinessPartners
but not for this one:
/api/sml.svc/LIF_cv_ServiceCallsParameters(FromDate='2019-11-04',ToDate='2019-11-11',CardCode='EMPTY',CallType=0,ProbType=0,ProbSubType=0,Status=0,Owner=0,Tech=0,LineStat='ASFC')/LIF_cv_ServiceCalls
I'm getting 404, not found
I have developed an Angular 8 application hosted in Azure App Service. The backend is located elsewhere and isn't CORS-enabled, so a reverse proxy is needed. I have followed parts of Ruslan's http://ruslany.net/2014/05/using-azure-web-site-as-a-reverse-proxy/. Plus, a lot of other posts around ARR reverse proxy.
Here is my applicationHost.xdt located in /site directory.
<?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">
</proxy>
<rewrite>
<allowedServerVariables>
<add name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" xdt:Transform="InsertIfMissing" />
<add name="HTTP_ACCEPT_ENCODING" xdt:Transform="Insert" />
<add name="HTTP_X_ORIGINAL_HOST" xdt:Transform="InsertIfMissing" />
</allowedServerVariables>
</rewrite>
</system.webServer>
</configuration>
The rules in web.config:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Angular Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true"/>
</conditions>
<action type="Rewrite" url="/index.html" />
</rule>
<rule name="proxy" stopProcessing="true">
<match url="api/(.*)" />
<action type="Rewrite" url="http://XX.XX.XX.XX:50001/b1s/v1/{R:1}"/>
<serverVariables>
<!--set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="{HTTP_ACCEPT_ENCODING}" /-->
<set name="HTTP_ACCEPT_ENCODING" value="" />
</serverVariables>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Parts of FailedRequestLog:
76. URL_CHANGED
OldUrl="/api/sml.svc/LIF_cv_ServiceCallsParameters(FromDate='2019-01-01',ToDate='2050-01-01',CardCode='EMPTY',CallType=0,ProbType=0,ProbSubType=0,Status=0,Owner=0,Tech=0,LineStat='U')/LIF_cv_ServiceCalls",
NewUrl="http://XX.XX.XX.XX:50001/b1s/v1/sml.svc/LIF_cv_ServiceCallsParameters(FromDate='2019-01-01',ToDate='2050-01-01',CardCode='EMPTY',CallType=0,ProbType=0,ProbSubType=0,Status=0,Owner=0,Tech=0,LineStat='U')/LIF_cv_ServiceCalls"
87. AspNetStart Data1="GET", Data2="/api/sml.svc", Data3=""
The exact call in NewUrl
works in PostMan.
It seems that the rewrite rule treats the url in the right way but the call is not made to the backend (verified with wireshark in remote machine). Instead, AspNetStart is trying to read a file or folder api/sml.svc, that finally results in the 404 code.
Any suggestions how to get this to work is highly appreciated!
This is finally solved!
I invoked Azure support for this issue. They found that the reason for not working was a failed authentication for the call that seems to be a svc service.
Adding a SVC handler solved the issue:
<system.webServer>
<handlers>
<remove name="svc-Integrated-4.0" />
<add name="svc-Integrated-4.0"
path="api/sml.svc/*."
verb="*"
type=" System.ServiceModel.Activation.ServiceHttpHandlerFactory, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
For the records: the backend is SAP Business One Servicel Layer. The sml.svc path is for custom made calculation views exposed via the Service Layer.