[英]URL Rewrite works for all my urls except one
我的 ARR URL Rewrite 适用于所有简单的 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,找不到
我开发了一个托管在 Azure 应用服务中的 Angular 8 应用程序。 后端位于其他地方并且没有启用 CORS,因此需要反向代理。 我已经关注了 Ruslan 的http://ruslany.net/2014/05/using-azure-web-site-as-a-reverse-proxy/的部分内容。 另外,还有很多其他关于 ARR 反向代理的帖子。
这是我位于 /site 目录中的 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">
</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 中的确切调用适用于NewUrl
。
似乎重写规则以正确的方式处理 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 路径用于通过服务层公开的定制计算视图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.