反向代理不适用于 .svc url?

reverse proxy doesn't work with .svc url?

这是我尝试使用 url 将 IIS 中的 mysubdomaintarget.mytargetdomain.com 重写为 mysubdomainreal.myrealdomain.com

的反向代理
<configuration>
    <system.webServer>
        <tracing>
            <traceFailedRequests>
                <add path="*">
                    <traceAreas>
                        <add provider="ASPNET" areas="Infrastructure,Module,Page,AppServices" verbosity="Verbose" />
                        <add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,FastCGI,WebSocket,Rewrite,RequestRouting" verbosity="Verbose" />
                    </traceAreas>
                    <failureDefinitions statusCodes="400-999" />
                </add>
            </traceFailedRequests>
        </tracing>
        <rewrite>
            <rules>
                <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Rewrite" url="https://mysubdomainreal.myrealdomain.com/{R:1}" />
                    <serverVariables>
                        <set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="{HTTP_ACCEPT_ENCODING}" />
                        <set name="HTTP_ACCEPT_ENCODING" value="" />
                    </serverVariables>
                </rule>
            </rules>
            <outboundRules>
                <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
                    <match filterByTags="A, Form, Img" pattern="^http(s)?://mysubdomainreal.myrealdomain.com/(.*)" />
                    <action type="Rewrite" value="http{R:1}://mysubdomainreal.myrealdomain.com/{R:2}" />
                </rule>
                <rule name="RestoreAcceptEncoding" preCondition="NeedsRestoringAcceptEncoding">
                    <match serverVariable="HTTP_ACCEPT_ENCODING" pattern="^(.*)" />
                    <action type="Rewrite" value="{HTTP_X_ORIGINAL_ACCEPT_ENCODING}" />
                </rule>
                <preConditions>
                    <preCondition name="ResponseIsHtml1">
                        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                    </preCondition>
                    <preCondition name="NeedsRestoringAcceptEncoding">
                        <add input="{HTTP_X_ORIGINAL_ACCEPT_ENCODING}" pattern=".+" />
                    </preCondition>
                </preConditions>
            </outboundRules>
        </rewrite>
    </system.webServer>
</configuration>

如果我使用 mysubdomaintarget.mytargetdomain.com/myApp 调用网站,它会工作(呈现 page/etc)。但是如果我打电话给 mysubdomaintarget.mytargetdomain.com/myApp.svc 我得到一个 404。

为什么?这个配置我哪里错了?

编辑 这是 failedRequest 标记的属性:

<failedRequest url="http://mysubdomaintarget.mytargetdomain.com/myApp.svc"
               siteId="6"
               appPoolId="services"
               processId="2192"
               verb="GET"
               remoteUserName=""
               userName=""
               tokenUserName="NT AUTHORITY\IUSR"
               authenticationType="anonymous"
               activityId="{8000002B-0000-9900-B63F-84710C7967BB}"
               failureReason="STATUS_CODE"
               statusCode="404"
               triggerStatusCode="404"
               timeTaken="141"
               xmlns:freb="http://schemas.microsoft.com/win/2006/06/iis/freb"
               >

EDIT2

这是我从失败的请求跟踪中得到的最后一个事件:

<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
 <System>
  <Provider Name="WWW Server" Guid="{3A2A4E84-4C21-4981-AE10-3FDA0D9B0F83}"/>
  <EventID>0</EventID>
  <Version>1</Version>
  <Level>0</Level>
  <Opcode>2</Opcode>
  <Keywords>0x0</Keywords>
  <TimeCreated SystemTime="2021-05-11T09:26:41.979Z"/>
  <Correlation ActivityID="{80000549-1000-FB00-B63F-84710C7967BB}"/>
  <Execution ProcessID="2192" ThreadID="2264"/>
  <Computer>MyPC</Computer>
 </System>
 <EventData>
  <Data Name="ContextId">{80000549-1000-FB00-B63F-84710C7967BB}</Data>
  <Data Name="BytesSent">2180</Data>
  <Data Name="BytesReceived">993</Data>
  <Data Name="HttpStatus">404</Data>
  <Data Name="HttpSubStatus">0</Data>
 </EventData>
 <RenderingInfo Culture="en-US">
  <Opcode>GENERAL_REQUEST_END</Opcode>
 </RenderingInfo>
 <ExtendedTracingInfo xmlns="http://schemas.microsoft.com/win/2004/08/events/trace">
  <EventGuid>{D42CF7EF-DE92-473E-8B6C-621EA663113A}</EventGuid>
 </ExtendedTracingInfo>
</Event>

它根本不是在“说话”。我在哪里可以看到上次活动的任何错误?

EDIT3

xml 浏览器打开:

为了允许 WCF 使用多个域,您应该将 multipleSiteBindingsEnabled 设置为 true。 以下配置应该可以解决您的问题。

<system.serviceModel>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>

multipleSiteBindingsEnabled

A Boolean value that specifies whether multiple IIS bindings per site is enabled.

IIS consists of web sites, which are containers for virtual applications containing virtual directories. The application in a site can be accessed through one or more IIS binding. An IIS binding provides two pieces of information: a binding protocol and binding information. Binding protocol defines the scheme over which communication occurs, and binding information is the information used to access the site. An example of a binding protocol can be HTTP, whereas binding information can contain an IP address, Port, host header, etc.

IIS supports specifying multiple IIS bindings per site, which results in multiple base addresses per scheme. However, a Windows Communication Foundation (WCF) service hosted under a site allows binding to only one baseAddress per scheme.

To enable multiple IIS bindings per site for a Windows Communication Foundation (WCF) service, set this attribute to true. Notice that multiple site binding is supported only for the HTTP protocol. The address of endpoints in the configuration file needs to be a complete URI.