I have a self-hosted API running on port 8080. On port 80 is my web server (IIS 7.5) with a website I can't touch. I added an application "MyApiTestsite". Now all requests to /api/ or /signalr/ I would like to forward to port 8080:
http://mycompany/MyApiTestsite -> untouched
http://mycompany/MyApiTestsite/signalr/* -> http://mycompany:8080/signalr/*
http://mycompany/MyApiTestsite/api/* -> http://mycompany:8080/api/*
I already installed ARR
(is this even necessary?) and URL Rewrite
.
Here's my rule I have so far (for SignalR):
<rule name="Rewrite SignalR to port 8080" patternSyntax="Wildcard" stopProcessing="true">
<match url="signalr/*" />
<serverVariables>
<set name="SERVER_PORT" value="8080" />
</serverVariables>
<action type="Rewrite" url="{R:0}" appendQueryString="true" logRewrittenUrl="false" />
</rule>
I checked the log-files and the rule gets matched. However, it doesn't work at all:
- I don't know how to get rid of the RelativePath (my application)
MyApiTestsite
- If I check logs the port didn't get replaced
Log:
RULE_EVALUATION_END RuleName="Rewrite SignalR to port 8080", RequestURL="MyApiTestsite/signalr/hubs", QueryString="", StopProcessing="true", Succeeded="true"
URL_REWRITE_END RequestURL="/MyApiTestsite/signalr/hubs"
GENERAL_CHILD_REQUEST_START SiteId="4", RequestURL="http://mycompany:80/MyApiTestsite/signalr/hubs", RequestVerb="GET", RecursiveLevel="1"
Update: I now tried it according to this post. However, it still doesn't work. The URL seems good but the MvcHandler takes over and returns a 404:
URL_REWRITE_END RequestURL="http://mycompany:8080/signalr/hubs"
USER_SET AuthType="", UserName="", SupportsIsInRole="true"
HANDLER_CHANGED
OldHandlerName="ExtensionlessUrlHandler-Integrated-4.0", NewHandlerName="System.Web.Mvc.MvcHandler", NewHandlerModules="ManagedPipelineHandler", NewHandlerScriptProcessor="", NewHandlerType="System.Web.Mvc.MvcHandler, System.Web.Mvc, Version=5.1.0.0"GENERAL_SEND_CUSTOM_ERROR HttpStatus="404", HttpSubStatus="4", FileNameOrURL="404.htm"
Update 2:
Here's a picture of what I want to do...
Update 3
This time I tried using Server Farms
instead. My URL got changed as it's supposed to be but then it got changed back to the old URL:
ARR_WEBFARM_ROUTED WebFarm="mycompany API", Algorithm="LeastRequests"
HANDLER_CHANGED OldHandlerName="", NewHandlerName="ApplicationRequestRoutingHandler", NewHandlerModules="ApplicationRequestRouting", NewHandlerScriptProcessor="", NewHandlerType=""
ARR_SERVER_ROUTED RoutingReason="LoadBalancing", Server="mycompany", State="Active", TotalRequests="1", FailedRequests="0", CurrentRequests="1", BytesSent="0", BytesReceived="0", ResponseTime="0"
GENERAL_SET_REQUEST_HEADER HeaderName="Max-Forwards", HeaderValue="10", Replace="true"
GENERAL_SET_REQUEST_HEADER HeaderName="X-Forwarded-For", HeaderValue="xxx.xx.xx.xxx:52327", Replace="true"
GENERAL_SET_REQUEST_HEADER HeaderName="X-ARR-SSL", HeaderValue="", Replace="true"
GENERAL_SET_REQUEST_HEADER HeaderName="X-ARR-ClientCert", HeaderValue="", Replace="true"
GENERAL_SET_REQUEST_HEADER HeaderName="X-ARR-LOG-ID", HeaderValue="f8exxxc2-7a6d-4cf6-a3c6-ecde245a0d80", Replace="true"
GENERAL_SET_REQUEST_HEADER HeaderName="Connection", HeaderValue="", Replace="true"
//>>>>>now it gets changed back!!! Why????<<<<<<
URL_CHANGED OldUrl="http://mycompany API/signalr/hubs", NewUrl="/MyApiTestsite/signalr/hubs"