将基于ant-design-pro前端框架开发的应用独立部署在IIS上

IIS 【URL重写】入站规则

参考博客:https://www.cnblogs.com/jsonzheng/articles/6606143.html

安装ARR

下载安装ARR(Application Request Routing),可通过【Web平台安装程序】,安装成功后会多出 【Application Request Routing Cache】和【URL重写】图标,如下图:

本文解决的主要问题

将对http://192.168.31.113:8101/api/xxx的请求转发至http://192.168.31.110:2893/Web/WebService/xxx

匹配URL规则

^(.*?)/?api/(.*)$

条件规则

{HTTP_HOST}

^192.168.31.113:8101$

操作规则

http://192.168.31.110:2893/Web/WebService/{R:2}

配置完后站点目录下的web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="test" stopProcessing="true">
                    <match url="^(.*?)/?api/(.*)$" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="^192.168.31.113:8101$" />
                    </conditions>
                    <action type="Rewrite" url="http://192.168.31.110:2893/Web/WebService/{R:2}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

猜你喜欢

转载自www.cnblogs.com/yuzhihui/p/9335035.html
今日推荐