检查服务器
打开IIS服务,看系统有没有这两个模块Application Request Routing Cache和URL重写(URL Rewrite)两个模块
安装模块
下载并安装 x64模块
ARR(Application Request Routing Cache): www.iis.net/downloads/m…
URL重写: www.iis.net/downloads/m…
安装后关闭软件重新打开
设置Request Routing Cache
设置proxy
勾选并应用
配置代理
前端根目录下新建web.config文件,修改配置中代理路径
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="api" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
<match url="*api/*" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="http://192.168.1.100:9002/{R:2}" />
</rule>
<rule name="index" enabled="true">
<match url="^((?!(api)).)*$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="/index.html" />
</rule>
</rules>
</rewrite>
<defaultDocument>
<files>
<clear />
<add value="index.html" />
<add value="Default.htm" />
<add value="Default.asp" />
<add value="index.htm" />
<add value="iisstart.htm" />
<add value="default.aspx" />
</files>
</defaultDocument>
</system.webServer>
</configuration>