基本上,我想使用反向代理重写URL:
从:
http://www.xyz.in/eacc/api/fetchVendors
到:
http://localhost:8080/eacc/api/fetchVendors
我已经在C:\Tomcat\apache-tomcat-9.0.7\webapps\eacc下部署了我的Spring Boot RESTful Web服务应用程序。
它包含许多POST调用,如/eacc/api/fetchVendors、/eacc/api/users、/eacc/api/clients等。
现在我想通过IIS公开这个eacc REST应用程序。
我有一个名为www.xyz.in的主要网站。
在网站(www.xyz.in)下添加了虚拟目录/eacc。物理路径:C:\inetpub\wwwroot\eacc。下面是web.config文件。
当我尝试访问一个POST调用,例如www.xyz.in/eacc/api/fetchVendors时,会出现HTTP 404服务器错误。
描述:HTTP 404。您正在查找的资源(或其某个依赖项)可能已被删除、更改名称或暂时不可用。请检查以下URL,确保拼写正确。
请求的URL:/eacc/api/fetchVendors
我的web.config文件为/eacc - 虚拟目录
<?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>
我是一个新手,正在使用IIS Web服务器。我遇到了URL Rewrite反向代理模式的问题。我尝试了很多模式更改,但没有成功。希望得到任何人的帮助。