Reputation: 47945
here's my attempt to do a reverse proxy using url rewrite in IIS
from mysubdomaintarget.mytargetdomain.com
to 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>
If I call website using mysubdomaintarget.mytargetdomain.com/myApp
it works (render the page/etc). But if I call mysubdomaintarget.mytargetdomain.com/myApp.svc
I got an 404.
Why? Where am I wrong on this configuration?
EDIT Here's the failedRequest tag's attribute:
<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
Here's the last event I got from failed request tracking:
<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>
its not "talking" at all. Where do I see any error from this last Event?
EDIT3
xml opened by browser:
Upvotes: 1
Views: 254
Reputation: 16192
In order to allow WCF to use multiple domain you should set multipleSiteBindingsEnabled
to true
.
The following configuration should fix your issue.
<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.
Upvotes: 2