《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

  

  

Azure Application Gateway (3) 设置URL路由的更多相关文章

  1. Azure Application Gateway (4) 设置URL路由 - PowerShell

    <Windows Azure Platform 系列文章目录> 本文将介绍如果使用Azure PowerShell,创建Azure Application Gateway URL Rout ...

  2. Azure Application Gateway (1) 入门

    <Windows Azure Platform 系列文章目录> 请读者注意,Azure Application Gateway在ASM模式下,只能通过PowerShell创建 具体可以参考 ...

  3. Azure Application Gateway(一)对后端 Web App 进行负载均衡

    一,引言 今天,我们学习一个新的知识点-----Azure Application Gateway,通过Azure 应用程序网关为我么后端的服务提供负载均衡的功能.我们再文章头中大概先了解一下什么是应 ...

  4. Azure Application Gateway(二)对后端 VM 进行负载均衡

    一,引言 上一节有讲到使用 Azure Application Gateway 为我们后端类型为 Web App 的 Demo 项目提供负载均衡,Azure Application Gateway 的 ...

  5. Azure Application Gateway (5) Application Gateway SSL Offload配置

    <Windows Azure Platform 系列文章目录> 之前有个客户提出了一个需求,他们的互联网访问的架构分为两种: 1.第一层是使用Azure Application Gatew ...

  6. Azure Application Gateway (2) 面向公网的Application Gateway

    <Windows Azure Platform 系列文章目录> 本章将介绍如何创建面向公网的Application Gateway,我们需要准备以下工作: 1.创建新的Azure Reso ...

  7. Windows Azure支持七层负载均衡--Application Gateway

    一直以来Windows Azure的负载均衡(Loadbalancer)功能一直被客户诟病,无法其竞争对手(特别是国内的云厂商)匹敌. Windows Azure的负载均衡器是四层的,前期的版本不支持 ...

  8. 【Azure 事件中心】为应用程序网关(Application Gateway with WAF) 配置诊断日志,发送到事件中心

    问题描述 在Application Gateway中,开启WAF(Web application firewall)后,现在需要把访问的日志输出到第三方分析代码中进行分析,如何来获取WAF的诊断日志呢 ...

  9. Ionic 动态配置url路由的设置

    随着Ionic App功能的不断增加,需要路由的url设置就越来越多,不喜欢在config函数中写一堆硬代码,一则不美,二则维护起来也麻烦,能不能把这些数据独立出来呢? 经过查找资料与各种实验,最终找 ...

随机推荐

  1. BJITJobs : 北京IT圈高端职位招聘信息,成功率最高的高端求职渠道

    你有实力,但比你差的人都升了,你的师弟都年薪50万了,你还是找不到机会.为什么你离高端机会总是差一步呢?其实你离成功就差一次机会,一个适合你的高端职位的信息! 招聘网站不靠谱:三大网站都是低端职位为主 ...

  2. ubuntu环境下vmware取消自动启动服务

    概述其实vmware这个服务取不取消,影响不大,主要是我有强迫症,在不用虚拟机的时候,看着vmware占着进程真心不爽,想要解决这个问题,在用虚拟机的时候启动服务,反之,则停.接下来,我说一下实现吧. ...

  3. Solve VS2010 Error "Exceptions has been thrown by the target of an invocation"

    Sometimes when you open a VS2010 project, an error window will pop up with the error message "E ...

  4. android的EditText重新获取焦点问题

    在android开发过程中关于EditText在setFocusable(false);后,当需要再次获得焦点输入时设置setFocusable(true);后还是无法获得焦点的问题: 解决办法: 对 ...

  5. 吐槽scala

    scala可能是唯一一个编译器和IDE对代码有不同理解的语言.当你开始用scala的高级特性的时候,他们的分歧特别的大,以至于现在,intellij上的scala插件已经不敢对可能编译不通过的代码标记 ...

  6. [.net 面向对象程序设计进阶] (25) 团队开发利器(四)分布式版本控制系统Git——使用GitStack+TortoiseGit 图形界面搭建Git环境

    [.net 面向对象程序设计进阶] (25) 团队开发利器(四)分布式版本控制系统Git——使用GitStack+TortoiseGit 图形界面搭建Git环境 本篇导读: 前面介绍了两款代码管理工具 ...

  7. 企业IT管理员IE11升级指南【2】—— Internet Explorer 11 对Adobe Flash的支持

    企业IT管理员IE11升级指南 系列: [1]—— Internet Explorer 11增强保护模式 (EPM) 介绍 [2]—— Internet Explorer 11 对Adobe Flas ...

  8. 分享一个css3写的气泡对话框,适合于即时通讯和留言本的动态内容

    效果预览: css code .message_content{width:100%;margin-top:10px;clear:both;float:left;} .face{float:left; ...

  9. <canvas>drawImage()方法无法显示图片

    在书上看到用<canvas>绘制图像就动手试试,刚开始,我的代码是这样的: <!DOCTYPE html> <html> <head> <meta ...

  10. 体验了微信小程序,发现安卓用户终于把果粉“碾压”了一次

    今天早上,张小龙在微信公开课上分享了小程序的理念,并且公布了小程序将于1月9日上线. 为了体现张小龙对未来程序形态的理解,小程序有四个特定:无需安装.触手可及.用完即走.无需卸载.今天,36氪刚好有机 ...