Good afternoon,
I need a reverse proxy solution to forward API calls from a server to different clients. I wanted to use an IIS with ARR for this. The address of the target client is included in the HTTP call of the server:
http://Proxyserver/Targetcomputer/API_String
I would like to rewrite the URL to: http://Targetcomputer/API_String
I have set up a URL rewrite rule with the following pattern:
`^(.*)/(.*)`
This leads to the following result:
`{R:0} Targetcomputer/API_String`
`{R:1} Targetcomputer`
`{R:2} API_String`
I use the following expression for the paraphrase:
`http://{R:1}/{R:2}`
However, it seems to me that dynamic redirection to {R:1}
is not possible.
Any suggestions from the smart guys?
Thank you in advance!
Andreas
Various forwarding rules created without success
The web server only seems to be able to access local resources.
Here are the Rewrite Rule out of web.config:
<rule name="Test" enabled="true" stopProcessing="true">
<match url="^([^/]+)/([^/]+)" />
<action type="Rewrite" url="http://{R:1}/{R:2}" LogRewrittenUrl="true" />
</rule>
Some more information, here are the details out of Failed Request Log:
<failedRequest url="http://localhost:80/www.ibm.com"
siteId="1"
appPoolId="DefaultAppPool"
processId="9580"
verb="GET"
remoteUserName=""
userName=""
tokenUserName="NT-AUTORITÄTIUSR"
authenticationType="anonymous"
activityId="{4000011E-0000-F000-B63F-84710C7967BB}"
failureReason="STATUS_CODE"
statusCode="404"
triggerStatusCode="404"
timeTaken="47"
xmlns:freb="http://schemas.microsoft.com/win/2006/06/iis/freb"
>
The URL_REWRITE Section:
<Opcode>URL_REWRITE_START</Opcode>
<Keywords>
<Keyword>Rewrite</Keyword>
</Keywords>
<freb:Description Data="Scope">Global</freb:Description>
<freb:Description Data="Type">Inbound</freb:Description>
</RenderingInfo>
<ExtendedTracingInfo xmlns="http://schemas.microsoft.com/win/2004/08/events/trace">
<EventGuid>{0469ABFA-1BB2-466A-B645-E3E15A02F38B}</EventGuid>
</ExtendedTracingInfo>
</Event>
<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>5</Level>
<Opcode>3</Opcode>
<Keywords>0x400</Keywords>
<TimeCreated SystemTime="2024-09-12T07:37:35.518Z"/>
<Correlation ActivityID="{4000011E-0000-F000-B63F-84710C7967BB}"/>
<Execution ProcessID="9580" ThreadID="1488"/>
<Computer>1BLUE</Computer>
</System>
<EventData>
<Data Name="ContextId">{4000011E-0000-F000-B63F-84710C7967BB}</Data>
<Data Name="RuleName">Forwarding</Data>
<Data Name="RequestURL">www.ibm.com</Data>
<Data Name="QueryString"></Data>
<Data Name="PatternSyntax">0</Data>
<Data Name="StopProcessing">true</Data>
<Data Name="RelativePath">/</Data>
</EventData>
<RenderingInfo Culture="de-DE">
<Opcode>RULE_EVALUATION_START</Opcode>
<Keywords>
<Keyword>Rewrite</Keyword>
</Keywords>
<freb:Description Data="PatternSyntax">Regex</freb:Description>
</RenderingInfo>
<ExtendedTracingInfo xmlns="http://schemas.microsoft.com/win/2004/08/events/trace">
<EventGuid>{0469ABFA-1BB2-466A-B645-E3E15A02F38B}</EventGuid>
</ExtendedTracingInfo>
</Event>
<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>5</Level>
<Opcode>10</Opcode>
<Keywords>0x400</Keywords>
<TimeCreated SystemTime="2024-09-12T07:37:35.518Z"/>
<Correlation ActivityID="{4000011E-0000-F000-B63F-84710C7967BB}"/>
<Execution ProcessID="9580" ThreadID="1488"/>
<Computer>1BLUE</Computer>
</System>
<EventData>
<Data Name="ContextId">{4000011E-0000-F000-B63F-84710C7967BB}</Data>
<Data Name="Pattern">^(.*)/(.*)</Data>
<Data Name="Input">www.ibm.com</Data>
<Data Name="Negate">false</Data>
<Data Name="Matched">false</Data>
</EventData>
<RenderingInfo Culture="de-DE">
<Opcode>PATTERN_MATCH</Opcode>
<Keywords>
<Keyword>Rewrite</Keyword>
</Keywords>
</RenderingInfo>
<ExtendedTracingInfo xmlns="http://schemas.microsoft.com/win/2004/08/events/trace">
<EventGuid>{0469ABFA-1BB2-466A-B645-E3E15A02F38B}</EventGuid>
</ExtendedTracingInfo>
</Event>
<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>5</Level>
<Opcode>4</Opcode>
<Keywords>0x400</Keywords>
<TimeCreated SystemTime="2024-09-12T07:37:35.518Z"/>
<Correlation ActivityID="{4000011E-0000-F000-B63F-84710C7967BB}"/>
<Execution ProcessID="9580" ThreadID="1488"/>
<Computer>1BLUE</Computer>
</System>
<EventData>
<Data Name="ContextId">{4000011E-0000-F000-B63F-84710C7967BB}</Data>
<Data Name="RuleName">Forwarding</Data>
<Data Name="RequestURL">www.ibm.com</Data>
<Data Name="QueryString"></Data>
<Data Name="StopProcessing">true</Data>
<Data Name="Succeeded">false</Data>
</EventData>
<RenderingInfo Culture="de-DE">
<Opcode>RULE_EVALUATION_END</Opcode>
<Keywords>
<Keyword>Rewrite</Keyword>
</Keywords>
</RenderingInfo>
<ExtendedTracingInfo xmlns="http://schemas.microsoft.com/win/2004/08/events/trace">
<EventGuid>{0469ABFA-1BB2-466A-B645-E3E15A02F38B}</EventGuid>
</ExtendedTracingInfo>
</Event>
<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>4</Level>
<Opcode>2</Opcode>
<Keywords>0x400</Keywords>
<TimeCreated SystemTime="2024-09-12T07:37:35.518Z"/>
<Correlation ActivityID="{4000011E-0000-F000-B63F-84710C7967BB}"/>
<Execution ProcessID="9580" ThreadID="1488"/>
<Computer>1BLUE</Computer>
</System>
<EventData>
<Data Name="ContextId">{4000011E-0000-F000-B63F-84710C7967BB}</Data>
<Data Name="RequestURL"></Data>
</EventData>
<RenderingInfo Culture="de-DE">
<Opcode>URL_REWRITE_END</Opcode>
3
I want to cut out the address of the proxy server
Then your action should be Redirect
instead of Rewrite
. you can refer to this blog to know about the difference of rewrite and redirect.
Try to use Rule below
<rule name="Test" enabled="true" stopProcessing="true">
<match url="^([^/]+)/([^/]+)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^proxyserver$">
</conditions>
<action type="Redirect" url="http://{R:1}/{R:2}" />
</rule>