Azure Lei Zhang的博客

weibo: LeiZhang的微博/QQ: 185165016/QQ群:319036205/邮箱:leizhang1984@outlook.com/TeL:139-161-22926

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

  《Windows Azure Platform 系列文章目录

  

  在之前的文章中,笔者介绍了Azure Web App可以设置URL路由。如下图:

  

 

  在这里笔者简单介绍一下,首先我们还是创建以下资源:

  1.创建一个新的Azure Resource Group,命名为LeiAppGWRG

  2.创建一个新的ARM Virtual Network,命名为LeiAppGatewayVNet

      有两个Subnet,分别为web-subnet,CIDR: 10.0.0.0/24

      另外一个subnet,叫appgateway-subnet,专门给Application Gateway使用,CIDR:10.0.1.0/24

  3.在创建新的Application Gateway,命名为:LeiAppGateway

  需要注意:如果我们要针对80端口设置URL Routing,我们必须设置Listener Configuration为Port 81

  不可以是Port 80,因为会被占用需要修改

  不可以是Port 80,因为会被占用需要修改

  不可以是Port 80,因为会被占用需要修改

  

  然后等Azure Application Gateway创建完毕  

 

 

  在这里还需要强调一下,当我们接下来还要操作的步骤:

  1.针对80端口,增加Listener

  2.不要修改和使用默认的appGatewayBackendPool

  3.在Backend Pools,创建新的imagesBackendPool,并设置Backend Addresses

  4.在Backend Pools,创建新的videosBackendPool,并设置Backend Addresses

  5.最后配置一下Application Gateway的Rules

 

 

  1.接下来开始第一部分,针对80端口,增加Listener

  我们选择Application Gateway,选择Listener,然后点击 + Basic。

  新增加针对80端口的Listerner: appGateway80Listener。如下图:

  

 

  2.不要修改和使用默认的appGatewayBackendPool

 

  3.选择Application Gateway,选择Backend Pool,然后点击Add。增加新的imagesBackendPool,并设置Backend Addresses

  当我们访问这个imagesBackendPool的时候,Application Gateway会把请求发送到内网IP为10.0.0.4和10.0.0.5的这2台VM

  

    

  

  4.选择Application Gateway,选择Backend Pool,然后点击Add。增加videosBackendPool,Address设置为10.0.0.11和10.0.0.12

  这样我们访问url路径为/images的时候,Application Gateway会把请求发送到内网IP为10.0.0.11和10.0.0.12的这2台VM

  

 

 

  5.最后,我们设置Rules,点击+ Path-based,命名为pathBasedRule。

  Listener选择之前创建的appGateway80Listener

  Default backend pool为appGatewayBackendPool

  注意下图的BackEndPool,选择默认的appGatewayBackendPool和我们新创建的imagessBackendPool。 

  需要注意,当我们访问Application Gateway的地址时候,访问逻辑是这样的:

  (1)如果我们访问URL路径为/images/*的时候,请求被发送到imagesBackendPool,对应的内网IP地址为10.0.0.4和10.0.0.5

  (2)如果我们访问URL路径为/videos/*的时候,请求被发送到videosBackendPool,对应的内网IP地址为10.0.0.11和10.0.0.12

  (3)当Path不匹配的时候,请求被发送到默认的imagesBackendPool。

  

   截图如下:

  

  

  6.准备Backend Pool所需要的虚拟机。

  然后我们在先创建新的Azure ARM Storage Account,然后创建4台Windows Server 2012 R2的虚拟机,对应的IP如下:

虚拟机名称 内网IP地址 Virtual Network子网 对应Application Gateway的Backend Pool 对应Application Gateway的访问URL路径 备注
ImagesVM01 10.0.0.4 web-subnet appGatewayBackendPool /images/* 安装IIS,增加虚拟目录images。修改IIS欢迎页面为虚拟机机器名
ImagesVM02 10.0.0.5 web-subnet appGatewayBackendPool /images/* 安装IIS,增加虚拟目录images。修改IIS欢迎页面为虚拟机机器名
VideosVM01 10.0.0.11 web-subnet videosBackendPool /videos/* 安装IIS,增加虚拟目录videos。修改IIS欢迎页面为虚拟机机器名
VideosVM02 10.0.0.12 web-subnet videosBackendPool /videos/* 安装IIS,增加虚拟目录videos。修改IIS欢迎页面为虚拟机机器名

  

  创建完毕后,请记住,因为我们针对Port 80设置Application Gateway,需要在上面的VM上安装IIS,并增加相应的虚拟目录。

  

  7.然后我们查看Azure Application Gateway,点击Overview,就可以查看到这个Application Gateway的动态IP(注意是动态IP地址,不是静态IP)和DNS Name。

  如下图:

  

  动态IP是: 139.219.234.106

  DNS是:ceca34df-a6ed-4914-8137-f44223e220e6.chinacloudapp.cn

 

  8.我们访问上面的Frontend Public IP Address,比如:

  http://139.219.234.106/images

  这个请求就会被发送到appGatewayBackendPool的两台VM,内网IP分为别10.0.0.4和10.0.0.5

  

 

  我们访问:http://139.219.234.106/videos/

  这个这个请求就会被发送到videosBackendPool的两台VM,内网IP分为别10.0.0.11和10.0.0.12

  

 

 

 

  

posted on 2016-12-27 15:23  Lei Zhang的博客  阅读(2945)  评论(2编辑  收藏  举报