【发布时间】:2020-04-11 13:16:17
【问题描述】:
我们正在将我们的主站点分解为微服务。最初,当我们拆分网站的一部分时,它将在我们的原始服务器上成为它自己的网站,直到它可以移动到它自己的容器中。
这个站点目前是一个 Angular 站点,所以你看我们有规则重写所有内容以转到 index.html。我正在尝试添加一个额外的规则,所以如果它找到了 url。 www.domainname.com/api/auth/.* 到 localhost:8001/{R:1}
我的理解是它将从 /auth/ 之后的 url 中获取所有内容并将其更改为 localhost:8001/{stuff after}
发生的事情是它遵循将所有内容指向索引文件的规则,并且似乎忽略了我的新规则。我第一次和最后一次都试过了,所以我假设我的规则一定有问题。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Api Rule">
<match url="domainname.com/api/auth/.*" />
<action type="Rewrite" url="localhost:8001/{R:1}" appendQueryString="false" />
</rule>
<rule name="AngularJS 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="/" />
</rule>
<rule name="CanonicalHostNameRule1">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.domainname\.com$" negate="true" />
</conditions>
<action type="Redirect" url="http://www.domainname.com/{R:1}" />
</rule>
<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>
</rules>
</rewrite>
</system.webServer>
</configuration>
【问题讨论】:
标签: angular iis url-rewriting microservices