以下是代理配置的一部分用于开发
{
context: "/api/oauth2",
pathRewrite: { "^/api": "" },
target: "https://somedomain.com",
changeOrigin: true,
secure: false,
},
实际上,我们已经使用Angular 8.0开发了一个应用程序。现在,我们要在启用了https SSL的IIS上进行部署。当我们将XHR发送到此URL / api / oauth2时,它不会重定向到我的专用URL,因为IIS上缺少代理配置。在IIS的ARR网址重写模块中该如何做?还是有其他方法可以处理此问题。
提前感谢。
Anand Kumar
您需要一个web.config
文件,它是IIS配置文件。这样可以解决您的Angular路由问题。将文件放在应用程序主目录中。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to https" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
</rule>
<rule name="Angular Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="./index.html" />
</rule>
</rules>
</rewrite>
<modules>
<remove name="WebDAVModule" />
</modules>
<httpErrors existingResponse="PassThrough" />
</system.webServer>
</configuration>
您可能还需要处理程序以允许HTTP方法。
要在iis中使用反向代理,您需要在iis中安装以下扩展名:
在网站的web.configf文件中添加以下规则:
<rule name="ReverseProxyInboundRule3" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://https://somedomain.com/{R:1}" />
</rule>