【问题标题】:Windows server2012r2 how to create multiple subdomain siteWindows server 2012 r2 如何创建多个子域站点
【发布时间】:2021-11-10 15:20:32
【问题描述】:

我正在创建一个接受用户作为子域的应用程序,
例如:{user_id}.mywebsite.com,因此,每个请求都必须是 *.mywebsite.com。

问题是每个子域都必须在 iis 上绑定 user1.mywebsite.com
user2.mywebsite.com 等
我的问题是,有没有办法设置一个域站点来接受每个子域请求?

这基本上是我想做的

有什么方法可以在不将每个用户作为子域添加到 iis 站点的情况下做到这一点?
提前致谢。

【问题讨论】:

    标签: iis windows-server-2012-r2 asp.net-core-mvc-2.0


    【解决方案1】:

    您可以设置一个包罗万象的站点,然后使用 ARR 转发流量,

    <system.webServer>
        <rewrite>
            <rules>
                <rule name="site1" stopProcessing="true">
                    <match url=".*" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="^(.*).site1.com$" />
                    </conditions>
                    <action type="Rewrite" url="http://localhost:8091/{R:0}" />
                </rule>
                <rule name="site2" stopProcessing="true">
                    <match url=".*" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="^(.*).site2.com$" />
                    </conditions>
                    <action type="Rewrite" url="http://localhost:8092/{R:0}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
    

    其他支持步骤可见this blog post

    【讨论】:

    • 谢谢 Lex,实际上通过阅读这篇博客,我决定升级将是一个更简单(更好)的解决方案,因为 iis10 提供了通配符主机支持,因此它允许创建一个全 (*) 子域主机.
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-02
    • 2022-12-03
    • 2018-10-24
    相关资源
    最近更新 更多