IIS: URL rewrite / signalr / and / api / to port 8080

I have my own hosting API running on port 8080. On port 80, I can’t touch my web server (IIS 7.5) with a website. I added the application "MyApiTestsite". Now I would like to forward all requests to / api / or / signalr / 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 is my rule that I still have (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 correct match. However, it does not work at all:

  • I do not know how to get rid of RelativePath (my application) MyApiTestsite
  • If I check the logs, the port is not 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 this according to this post. However, it still does not work. The url seems good, but MvcHandler takes over and returns 404:

URL_REWRITE_END RequestURL = "http: // mycompany: 8080 / signalr / hubs"

USER_SET AuthType = ", UserName =" ", SupportsIsInRole =" true "

HANDLER_CHANGED
OldHandlerName = "ExtensionlessUrlHandler-integrally-4.0", NewHandlerName = "System.Web.Mvc.MvcHandler", NewHandlerModules = "ManagedPipelineHandler", NewHandlerScriptProcessor = "", NewHandlerType = "System.WebWMvler.v. Mvc, Version = 5.1.0.0 "

GENERAL_SEND_CUSTOM_ERROR HttpStatus = "404", HttpSubStatus = "4", FileNameOrURL = "404.htm"

Update 2:

Here is a picture of what I want to do ...

enter image description here

Update 3 This time I tried to use Server Farms instead. My URL was changed as expected, but then it was changed 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" 
+8
url-rewriting iis signalr self-hosting arr
source share
2 answers

Configure the following Rewrite URL rule:

 Requested URL: Matches the pattern Using: Regular Expressions Pattern: MyApiTestsite/(signalr/.*) Action: Rewrite Rewrite URL: http://mycompany:8080/{R:1} 

EDIT: {R:1} corresponds to the first group of captured regexp in this case, which corresponds to (signalr/.*) . If it were {R:0} instead, it would put all the relative URL that was mapped. See the IIS URL Rewrite {R: N} for more details.

0
source share

Try the following: it works!

 <rewrite> <rewriteMaps> <rewriteMap name="root"> <add key="/root/" value="/" /> </rewriteMap> </rewriteMaps> <rules> <clear /> <rule name="MyRedirect" stopProcessing="true"> <match url="^MYApiTestsite/(api|signalr)(/.*)?" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false" /> <action type="Redirect" url="http://mycompany:8080/{R:1}{R:2}" /> </rule> </rules> </rewrite> 

If you want to use the GUI then enter image description here

0
source share

All Articles