简体   繁体   English

IIS URL重写域到多个VM之一

[英]IIS URL Rewrite domain to one of several VMs

I have a server running several Virtual Machines. 我有一台运行多个虚拟机的服务器。 Each VM runs IIS 8.0 and hosts a variety of different sites. 每个VM运行IIS 8.0,并承载各种不同的站点。 The base server is also running IIS 8.0 and I'm intending that it directs requests to one of of the VMs depending on the HTTP_HOST. 基本服务器也正在运行IIS 8.0,我打算根据HTTP_HOST将请求定向到其中一个VM。

I'm trying to define the inbound and outbound rules to achieve the following: 我正在尝试定义入站和出站规则以实现以下目的:

www.mydomain1.com requests are directed to VM 192.168.1.10/mydomain1

www.mydomain2.com requests are directed to VM 192.168.1.10/mydomain2

www.mydomain3.com requests are directed to VM 192.168.1.11/mydomain3 

www.mydomain4.com requests are directed to VM 192.168.1.11/mydomain4

What I want is for the user to see www.mydomainx.com all the time while the internal VM serves up the pages seamlessly without changing the URL. 我想要的是让用户始终看到www.mydomainx.com,而内部VM无缝地为页面提供服务而无需更改URL。 I've spent hours trying every combination I can think of and read dozens of posts but none seem to cover this particular scenario. 我已经花了数小时尝试我能想到的每种组合,并阅读了数十篇文章,但似乎没有一篇涵盖这种特殊情况。

I've got subdomain to folder working (mysub.mydomain.com -> 192.168.1.10/mysub but not full domain name. 我已经将子域设置为可工作的文件夹(mysub.mydomain.com-> 192.168.1.10/mysub,但没有完整的域名。

Any suggestions gratefully received. 任何建议表示感谢。

After a lot of searching and testing I've finally found the solution. 经过大量搜索和测试,我终于找到了解决方案。 Instructions below relate to IIS 8.5. 以下说明与IIS 8.5有关。

  1. Install Application Request Routing Extension for IIS 为IIS安装应用程序请求路由扩展
  2. Install URL Rewrite 2.0 for IIS 安装IIS的URL Rewrite 2.0
  3. Restart IIS Manager and you should see a new node called Server Farms 重新启动IIS管理器,您应该看到一个名为Server Farms的新节点。
  4. For every Virtual Machine that hosts websites, create a Server Farm, then add the IP address of the VM as a server in that farm. 对于每个托管网站的虚拟机,创建一个服务器场,然后将VM的IP地址添加为该场中的服务器。 In my set up I have one VM per Server Farm. 在我的设置中,每个服务器场都有一个VM。
  5. Once you have all your VM's set up in their own Server Farm, select the root server node in IIS and double-click URL Rewrite 将所有VM设置在自己的服务器场中后,在IIS中选择根服务器节点,然后双击URL Rewrite。
  6. For each VM create rules for all the domains being handled. 为每个VM创建要处理的所有域的规则。

    • Add a new blank rule 添加新的空白规则
    • Add an appropriate name and set the Pattern to .* - regex for all matches 添加一个适当的名称,并将所有匹配项的Pattern设置为。*-regex
    • In the Conditions section, click Add 在“条件”部分中,单击“添加”。
    • Set Condition input to {SERVER_NAME} 将条件输入设置为{SERVER_NAME}
    • Make sure input string dropdown is set to Matches the Pattern 确保输入字符串下拉列表设置为“匹配模式”
    • Set the pattern to ^(www.)?yourdomain.com$ - set the domain name appropriately and click ok 将模式设置为^(www。)?yourdomain.com $-正确设置域名,然后单击“确定”。
    • Add conditions for every domain name that will be handled by the VM 为虚拟机将要处理的每个域名添加条件
    • In the Action section, set Action Type to Route to Server Farm 在“操作”部分,将“操作类型”设置为“路由到服务器场”
    • In the Action properties, select the server farm that will handle these domains 在“操作”属性中,选择将处理这些域的服务器场
    • Click Apply 点击应用

Now all you need to do is set up your router to port forward requests on port 80 to your base IIS server and it will then route traffic based on the domain names to the appropriate Virtual Machine. 现在,您所需要做的就是设置路由器,以将端口80上的转发请求移植到基本IIS服务器,然后它将根据域名将流量路由到适当的虚拟机。

I have four Virtual Machines set up this way the routing is seamless and works really well. 我用这种方式设置了四个虚拟机,路由是无缝的,并且运行得很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM