在 IIS 7.5 上的同一端口上运行两个网站?
我们需要能够在同一 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
ARR 和重写规则的结合可以很好地解决这个问题。请执行以下步骤:
http:*:80:< /代码>。将其命名为“默认网站”。将其物理路径指向“%SystemDrive%\inetpub\DefaultWebSite”
为“Default”网站创建一个 web.config 文件,并在其中写入路由规则:
<前><代码><规则>;
>
<规则名称=“实验反向代理”stopProcessing=“true”>
<匹配 url="^.*/experimental/.*" />
<规则名称=“发布反向代理”stopProcessing=“true”>
<匹配 url=".*" />
您可能需要对重写规则进行一些修改,您可以尝试使用 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:
http:*:80:
. Name it "Default Web Site". Point its physical path to "%SystemDrive%\inetpub\DefaultWebSite"Create a web.config file for the "Default" website, and write your routing rules there:
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).您可以在不同的子域(例如 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.