2

基本上我想使用反向代理重写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 重写反向代理模式。尝试了许多模式更改,但没有运气。寻求任何人的帮助。

4

2 回答 2

5

对我来说,这适用于 IIS:

转到 IIS 根节点 >> ARR

在此处输入图像描述

单击“服务器代理设置”选项

在此处输入图像描述

并启用它:

在此处输入图像描述

于 2020-07-09T18:10:03.787 回答
0
Inbound Rule:
Use Patters : ^eacc.*
Rewrite URL : http://localhost:8080/{R:0}

Outbound Rule:
Pattern : localhost:8080
Value : www.xyz.com

您还需要添加代理设置(应用程序请求路由模块 - 服务器代理设置):

(tick) Enable Proxy
(untick) REverse Rewrite in response headers
于 2018-10-24T13:44:55.940 回答