我有一个在端口 8080 上运行的自托管 API。在端口 80 上是我的 Web 服务器(IIS 7.5),其中有一个我无法访问的网站。我添加了一个应用程序“MyApiTestsite”。现在对 /api/ 或 /signalr/ 的所有请求我想转发到端口 8080:
http://mycompany/MyApiTestsite -> untouched
http://mycompany/MyApiTestsite/signalr/* -> http://mycompany:8080/signalr/*
http://mycompany/MyApiTestsite/api/* -> http://mycompany:8080/api/*
我已经安装了ARR
(这甚至有必要吗?)和URL Rewrite
.
这是我到目前为止的规则(对于 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>
我检查了日志文件并匹配了规则。但是,它根本不起作用:
- 我不知道如何摆脱RelativePath(我的应用程序)
MyApiTestsite
- 如果我检查日志,端口没有被替换
日志:
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"
更新: 我现在根据这篇文章进行了尝试。但是,它仍然不起作用。URL 看起来不错,但 MvcHandler 接管并返回 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 , 版本=5.1.0.0"GENERAL_SEND_CUSTOM_ERROR HttpStatus="404", HttpSubStatus="4", FileNameOrURL="404.htm"
更新 2:
这是我想做的图片...
更新 3
这次我尝试Server Farms
改用。我的 URL 已按原样更改,但随后又更改回旧 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"