在 IIS 7.5 上的同一端口上运行两个网站? [英] Run two web sites on same port on IIS 7.5?

查看:32
本文介绍了在 IIS 7.5 上的同一端口上运行两个网站?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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:inetpubwwwrootVersion1 => http://test1.organization.com/C:inetpubwwwrootVersion2 => http://test1.organization.com/experimental

C:inetpubwwwrootVersion1 => http://test1.organization.com/ C:inetpubwwwrootVersion2 => http://test1.organization.com/experimental

第一个 URL 已经暴露给一些 Beta 用户,因此需要保持一定程度的稳定.第二个将包含只有进入/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.

我过去通过将/映射到 IIS 中的站点下的站点,然后将第二个站点添加为它下面的应用程序,并将其别名为/site2 来实现这一点.

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.

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

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

然而,这看起来很草率.使用重写规则还是使用 ARR 执行此操作会更清晰吗?如果是,怎么办?

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

谢谢!

推荐答案

ARR 和重写规则的组合将很好地解决这个问题.以下是要遵循的步骤:

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

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

  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%inetpubDefaultWebSite"
  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>

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

  • 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/

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

    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).

    这篇关于在 IIS 7.5 上的同一端口上运行两个网站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆