Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何编写IIS将多个子域重写为多个本地端口规则?_Iis_Url Rewriting_Subdomain - Fatal编程技术网

如何编写IIS将多个子域重写为多个本地端口规则?

如何编写IIS将多个子域重写为多个本地端口规则?,iis,url-rewriting,subdomain,Iis,Url Rewriting,Subdomain,我想在IIS中为下面的列表设置反向代理规则 app1.application.com > localhost:26000 app2.application.com > localhost:26001 app3.application.com > localhost:26002 我在单个IIS站点中添加了绑定,然后为端口26000定义了单个规则。它们都重定向到端口27000上的应用程序 这是我补充的规则 <rule name="ReverseProxyInboundRul

我想在IIS中为下面的列表设置反向代理规则

app1.application.com > localhost:26000
app2.application.com > localhost:26001
app3.application.com > localhost:26002
我在单个IIS站点中添加了绑定,然后为端口26000定义了单个规则。它们都重定向到端口27000上的应用程序

这是我补充的规则

<rule name="ReverseProxyInboundRule1" stopProcessing="true">
    <match url="(.*)" />
    <action type="Rewrite" url="http://localhost:26000/{R:1}" />
</rule>

如何添加其他规则


像这样谢谢你。请注意第四条规则,我是如何临时重定向到internet URL的。这是一种“测试”脚本的简单方法,因为重定向和内部重写更简单。通常情况下,我使用重定向(同样,使用临时重定向),然后将其切换到内部重写

最后,您可以考虑在3之后添加一个catch重写,以重定向到一个错误页面或一个“默认”应用程序。由于这些规则是按顺序处理的(并且设置了停止处理),因此您只需添加该规则,而不必在最后添加HTTP_主机条件

            <rule name="ReverseProxyInboundRule1" enabled="true" stopProcessing="true">
                <match url="(.*)" />
                <action type="Rewrite" url="http://localhost:26000/{R:1}" />
                <conditions>
                    <add input="{HTTP_HOST}" pattern="^(app1\.application\.com)$" />
                </conditions>
            </rule>
            <rule name="ReverseProxyInboundRule2" enabled="true" stopProcessing="true">
                <match url="(.*)" />
                <action type="Rewrite" url="http://localhost:26001/{R:1}" />
                <conditions>
                    <add input="{HTTP_HOST}" pattern="^(app2\.application\.com)$" />
                </conditions>
            </rule>
            <rule name="ReverseProxyInboundRule3" enabled="true" stopProcessing="true">
                <match url="(.*)" />
                <action type="Rewrite" url="http://localhost:26002/{R:1}" />
                <conditions>
                    <add input="{HTTP_HOST}" pattern="^(app3\.application\.com)$" />
                </conditions>
            </rule>
            <rule name="ReverseProxyInboundRule4" enabled="false" stopProcessing="true">
                <match url="(.*)" />
                <action type="Redirect" url="http://www.google.com" redirectType="Temporary" />
                <conditions>
                    <add input="{HTTP_HOST}" pattern="^(app4\.application\.com)$" />
                </conditions>
            </rule>

像这样。请注意第四条规则,我是如何临时重定向到internet URL的。这是一种“测试”脚本的简单方法,因为重定向和内部重写更简单。通常情况下,我使用重定向(同样,使用临时重定向),然后将其切换到内部重写

最后,您可以考虑在3之后添加一个catch重写,以重定向到一个错误页面或一个“默认”应用程序。由于这些规则是按顺序处理的(并且设置了停止处理),因此您只需添加该规则,而不必在最后添加HTTP_主机条件

            <rule name="ReverseProxyInboundRule1" enabled="true" stopProcessing="true">
                <match url="(.*)" />
                <action type="Rewrite" url="http://localhost:26000/{R:1}" />
                <conditions>
                    <add input="{HTTP_HOST}" pattern="^(app1\.application\.com)$" />
                </conditions>
            </rule>
            <rule name="ReverseProxyInboundRule2" enabled="true" stopProcessing="true">
                <match url="(.*)" />
                <action type="Rewrite" url="http://localhost:26001/{R:1}" />
                <conditions>
                    <add input="{HTTP_HOST}" pattern="^(app2\.application\.com)$" />
                </conditions>
            </rule>
            <rule name="ReverseProxyInboundRule3" enabled="true" stopProcessing="true">
                <match url="(.*)" />
                <action type="Rewrite" url="http://localhost:26002/{R:1}" />
                <conditions>
                    <add input="{HTTP_HOST}" pattern="^(app3\.application\.com)$" />
                </conditions>
            </rule>
            <rule name="ReverseProxyInboundRule4" enabled="false" stopProcessing="true">
                <match url="(.*)" />
                <action type="Redirect" url="http://www.google.com" redirectType="Temporary" />
                <conditions>
                    <add input="{HTTP_HOST}" pattern="^(app4\.application\.com)$" />
                </conditions>
            </rule>