Reputation: 308
basically i wanna to rewrite url using reverse proxy: from:
http://www.xyz.in/eacc/api/fetchVendors
to
http://localhost:8080/eacc/api/fetchVendors
I have deployed my spring boot rest full web service application in tomcat under C:\Tomcat\apache-tomcat-9.0.7\webapps\eacc.
It contains many POST call like /eacc/api/fetchVendors, /eacc/api/users, /eacc/api/clients.. etc.
Now i wanna to expose this eacc rest application through IIS.
have main website configured called www.xyz.in.
added virtual directory under website (www.xyz.in) called /eacc. physical path: C:\inetpub\wwwroot\eacc below is web.config file.
When i try to hit one post call like www.xyz.in/eacc/api/fetchVendors, getting HTTP 404 server error.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /eacc/api/fetchVendors
My web.config file for /eacc - virtual directory
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpRedirect enabled="false" />
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://localhost:8080/eacc/{R:1}" />
</rule>
</rules>
<outboundRules>
<rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
<match filterByTags="A, Form, Img" pattern="^http(s)?://localhost:8080/eacc/(.*)" />
<action type="Rewrite" value="http{R:1}://www.xyz.in/{R:2}" />
</rule>
<preConditions>
<preCondition name="ResponseIsHtml1">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/(.+)" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
</system.webServer>
</configuration>
Am new to IIS web server.have stuck with URL Rewrite reverse proxy pattern. have tried many pattern changes but no luck. Looking help from anyone.
Upvotes: 3
Views: 9957
Reputation: 9630
For me, this worked on IIS:
Go to IIS root node >> ARR
Click "Server Proxy Settings" option
and enable it:
Upvotes: 11
Reputation: 63
Inbound Rule:
Use Patters : ^eacc.*
Rewrite URL : http://localhost:8080/{R:0}
Outbound Rule:
Pattern : localhost:8080
Value : www.xyz.com
Also you need to Add Proxy settings (Application Request Routing Module - Server Proxy settings) :
(tick) Enable Proxy
(untick) REverse Rewrite in response headers
Upvotes: 1