URL 重写适用于除一个以外的所有网址
URL Rewrite works for all my urls except one
我的 ARR URL 重写适用于所有简单 url:s 为
/api/Login
,
/api/BusinessPartners
但不是这个:
/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
我收到 404,未找到
我开发了一个 Angular 8 应用程序托管在 Azure 应用服务中。后端位于其他地方并且不支持 CORS,因此需要反向代理。我关注了 Ruslan 的 http://ruslany.net/2014/05/using-azure-web-site-as-a-reverse-proxy/ 的部分内容。
另外,还有很多关于 ARR 反向代理的其他帖子。
这是我的 applicationHost.xdt 位于 /site 目录。
<?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>
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>
部分 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=""
NewUrl
中的确切调用适用于 PostMan。
似乎重写规则以正确的方式处理了 url,但未对后端进行调用(在远程计算机中使用 wireshark 进行了验证)。
相反,AspNetStart 正在尝试读取文件或文件夹 api/sml.svc,最终导致 404 代码。
非常感谢任何有关如何让它工作的建议!
终于解决了!
我为这个问题调用了 Azure 支持。
他们发现无法工作的原因是对似乎是 svc 服务的调用的身份验证失败。
添加 SVC 处理程序解决了问题:
<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>
记录:后端是 SAP Business One Servicel Layer。 sml.svc 路径用于通过服务层公开的自定义计算视图。
我的 ARR URL 重写适用于所有简单 url:s 为
/api/Login
,
/api/BusinessPartners
但不是这个:
/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
我收到 404,未找到
我开发了一个 Angular 8 应用程序托管在 Azure 应用服务中。后端位于其他地方并且不支持 CORS,因此需要反向代理。我关注了 Ruslan 的 http://ruslany.net/2014/05/using-azure-web-site-as-a-reverse-proxy/ 的部分内容。 另外,还有很多关于 ARR 反向代理的其他帖子。
这是我的 applicationHost.xdt 位于 /site 目录。
<?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>
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>
部分 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=""
NewUrl
中的确切调用适用于 PostMan。
似乎重写规则以正确的方式处理了 url,但未对后端进行调用(在远程计算机中使用 wireshark 进行了验证)。 相反,AspNetStart 正在尝试读取文件或文件夹 api/sml.svc,最终导致 404 代码。
非常感谢任何有关如何让它工作的建议!
终于解决了!
我为这个问题调用了 Azure 支持。 他们发现无法工作的原因是对似乎是 svc 服务的调用的身份验证失败。
添加 SVC 处理程序解决了问题:
<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>
记录:后端是 SAP Business One Servicel Layer。 sml.svc 路径用于通过服务层公开的自定义计算视图。