在 IIS 7.5 上的同一端口上运行两个网站?

发布于 2024-11-30 02:42:34 字数 729 浏览 3 评论 0原文

我们需要能够在同一 Intranet 服务器和端口号上运行一个 ASP.net Web 应用程序的两个版本,但其中一个映射到 /,另一个映射到 /experimental(不是真实姓名,但足够接近)。

C:\inetpub\wwwroot\Version1 => http://test1.organization.com/ C:\inetpub\wwwroot\Version2 => http://test1.organization.com/experimental

第一个 URL 已向部分测试版用户公开因此需要保持一定的稳定。第二个将包含只有访问 /experimental 的用户才能看到的实验代码。我们无法选择使用不同的服务器或不同的端口。

我过去通过将 / 映射到 IIS 中“站点”下的站点,然后将第二个站点添加为其下的应用程序,并将其别名为 /site2 来实现此目的。

服务器 站点 默认网站 <= 映射到第一个版本的物理路径和/ /Application1 <= 映射到第二个版本的嵌套应用程序和 /experimental

但是,这看起来很草率。使用重写规则或 ARR 来完成此操作会更干净吗?如果是这样,怎么办?

We need to be able to run two versions of one ASP.net web application on the same intranet server and port number, but with one mapped to / and the other mapped to /experimental (not real names, but close enough).

C:\inetpub\wwwroot\Version1 => http://test1.organization.com/
C:\inetpub\wwwroot\Version2 => http://test1.organization.com/experimental

The first URL has already been exposed to some beta users and therefore needs to be kept somewhat stable. The second will contain experimental code that only users going to /experimental will see. We don't have the option of using a different server or a different port.

I've achieved this in the past by having / mapped to a site under Sites in IIS, then adding the second site as an application underneath it, and aliasing it to /site2.

Server
Sites
Default Web Site <= physical path mapped to first version and /
/ Application1 <= nested application mapped to second version and /experimental

However, this seems sloppy. Would it be cleaner to do this with a rewrite rule or with ARR? If so, how?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冷情妓 2024-12-07 02:42:34

ARR 和重写规则的结合可以很好地解决这个问题。请执行以下步骤:

  1. 下载并安装 ARR http://www.iis.net/download/ApplicationRequestRouting
  2. 在 IIS 管理器中,在“连接”窗格中选择您的计算机,双击 IIS 部分中的“应用程序请求路由”功能,单击“操作”窗格中的“服务器代理”链接,然后选中“启用代理”复选框并选择应用操作。
  3. 更改两个现有网站的绑定,例如将已发布网站绑定到端口 81,将实验网站绑定到端口 82。
  4. 创建新网站和应用程序池,并将其绑定到 http:*:80:< /代码>。将其命名为“默认网站”。将其物理路径指向“%SystemDrive%\inetpub\DefaultWebSite”
  5. 为“Default”网站创建一个 web.config 文件,并在其中写入路由规则:

    <前><代码><规则>;
    <规则名称=“实验反向代理”stopProcessing=“true”>
    <匹配 url="^.*/experimental/.*" />


    <规则名称=“发布反向代理”stopProcessing=“true”>
    <匹配 url=".*" />
    >


  6. 您可能需要对重写规则进行一些修改,您可以尝试使用 URL 重写模块IIS 上的小程序,并在此处阅读更多相关信息: http://learn.iis.net/page.aspx/500/testing-rewrite-rule-patterns/ 如需进一步帮助,请务必浏览 Ruslan Yakushev 的博客:http://ruslany.net/

这将为您提供三个完全独立的网站,可通过端口 80 上的单个外观进行访问(尽管当然,如果您需要,您可以直接在端口 81 和 82 上访问每个网站:例如 http://localhost:81/default.aspx)。

A combination of ARR and rewrite rules will solve this nicely. Here are the steps to follow:

  1. Download and install ARR http://www.iis.net/download/ApplicationRequestRouting
  2. In IIS Manager, select your machine in the Connections pane, double-click the Application Request Routing feature in the IIS section, click on the "Server Proxy" link in the Actions pane, then check the "Enable proxy" checkbox and choos the Apply action.
  3. Change the bindings of your two existing websites, for instance, bind the Released website to port 81, and the Experimental website to port 82.
  4. Create a new website and app pool, and bind it to http:*:80:. Name it "Default Web Site". Point its physical path to "%SystemDrive%\inetpub\DefaultWebSite"
  5. Create a web.config file for the "Default" website, and write your routing rules there:

    <rules>
        <rule name="Reverse Proxy for Experimental" stopProcessing="true">
            <match url="^.*/experimental/.*" />
            <action type="Rewrite" url="http://{HTTP_HOST}:82/{R:0}" />
        </rule>
        <rule name="Reverse Proxy for Release" stopProcessing="true">
            <match url=".*" />
            <action type="Rewrite" url="http://{HTTP_HOST}:81/{R:0}" />
        </rule>
    </rules>
    
  6. You may have to fiddle somewhat with your rewrite rules, you can experiment using the URL Rewrite Module applet on IIS, and read more about it here: http://learn.iis.net/page.aspx/500/testing-rewrite-rule-patterns/ For further help be sure and browse Ruslan Yakushev's blog: http://ruslany.net/

This will give you three completely separate websites, accessibly through a single facade on port 80 (though of course you can hit each website directly on port 81 and 82 if you need to: http://localhost:81/default.aspx, for example).

只是在用心讲痛 2024-12-07 02:42:34

您可以在不同的子域(例如 test1.organization.com 和 beta1.organization.com)上运行其中一个站点吗?如果是这样,那么您可以将它们都设置为 IIS 中的顶级网站,并在每个站点绑定上设置主机名,以便它们都可以在相同的 IP 地址和端口上运行。

Can you run one of the sites at a different subdomain, say test1.organization.com and beta1.organization.com? If so then you can set them both up as top-level websites in IIS and set the Host Name on each Site Binding so they can both run on the same IP address and port.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文