基本上我想使用反向代理重写url:来自:
http://www.xyz.in/eacc/api/fetchVendors
至
http://localhost:8080/eacc/api/fetchVendors
我已经在 C:\Tomcat\apache-tomcat-9.0.7\webapps\eacc 下的 tomcat 中部署了 Spring Boot Rest 完整的 Web 服务应用程序。
它包含许多 POST 调用,例如 /eacc/api/fetchVendors、/eacc/api/users、/eacc/api/clients.. 等。
现在我想通过 IIS 公开这个 eacc rest 应用程序。
已配置名为 www.xyz.in 的主网站。
在名为 /eacc 的网站 (www.xyz.in) 下添加了虚拟目录。物理路径:C:\inetpub\wwwroot\eacc 下面是 web.config 文件。
当我尝试打一个像www.xyz.in/eacc/api/fetchVendors这样的帖子调用时,收到 HTTP 404 服务器错误。
说明:HTTP 404。您要查找的资源(或其依赖项之一)可能已被删除、名称已更改或暂时不可用。请查看以下 URL 并确保其拼写正确。
请求的 URL:/eacc/api/fetchVendors
我的/eacc的 web.config 文件- 虚拟目录
<?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 重写反向代理模式。尝试了许多模式更改,但没有运气。寻求任何人的帮助。