将子域映射到虚拟目录Azure WebApp [英] Map subdomain to virtual directory Azure WebApps

查看:119
本文介绍了将子域映射到虚拟目录Azure WebApp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在一个Azure WebApp中托管多个网站,而不是让每个网站都托管多个Web应用程序.这些站点中的每个站点都很小,但是为了满足使用Azure的SLA的要求,我们需要在生产环境中使用不止一个实例来扩展服务器,从而进行站点合并.

I am attempting to host multiple websites in a single Azure WebApp rather than having multiple web apps each hosting a site. Each of these sites is rather small, but in order to meet the requirements of the SLA with Azure, we need to have the server scaled with more than one instance for our Production environment, thus the reasoning for combining sites.

研究完此主题后,我们使用Azure帐户进行了以下设置.

After researching this topic, I have got the following setup with our Azure account.

  1. 在我们的区域管理器中创建了正确的CNAME DNS记录(已完成且可以运行).
  2. 设置Azure WebApp以响应子域(完整且有效).
  3. 为第二个Web应用程序设置虚拟目录(已完成且可以正常运行)

此时,两个Web应用程序均正常运行,并且两个子域都指向我们的Azure实例.现在,我们进行以下设置:

At this point, both web applications function correctly and both subdomains are pointing at our Azure instance. We now have the following setup:

  • www.mydomain.com和app.mydomain.com都调出了我部署的根应用程序.
  • 进入www.mydomain.com/app2和app.mydomain.com/app2,调出我部署到虚拟目录的第二个应用程序

我想要实现的目标:

  • 转到app.mydomain.com将在虚拟目录中启动该应用程序.
  • 访问www.mydomain.com将在Azure实例的根目录处启动该应用程序.

但是,我无法确定的是如何将子域映射到特定的虚拟目录.我试图将站点URL更新为我希望应用程序响应的子域,但是,该子域仍然显示我在WebApp部署的根目录中拥有的任何内容.

However, what I cannot figure out is how to map a subdomain to a specific virtual directory. I have tried to update the Site URL to be the subdomain I want the application to respond to, however, the subdomain still brings up whatever I have in the root of the WebApp deployment.

我应该在站点根目录中有一些HttpHandler并将流量定向到正确的虚拟目录吗?我缺少门户中的设置吗?以前,我们是通过Web角色和ServiceDefinition文件来完成此操作的,但是Azure Web Apps在发布,与Source Control集成等方面的工具集似乎还有一段距离.

Should I have some HttpHandler that sits in the site root and directs traffic to the proper virtual directory? Is there a setting in the portal that I am missing? Previously, we did this with Web Roles and tinkering with the ServiceDefinition file, but the tool sets for the Azure Web Apps in regards to publishing, integration with Source Control, etc seem to be a bit further along.

推荐答案

RuslanY发布的答案有效(对规则进行了一些修改),但是,在了解了更多的Azure门户和Web App配置之后,它不是需要在一个Web应用程序中托管多个站点(从技术上讲,多个Web应用程序都共享您定义的资源计划,例如2个Standard Level 0(S0)实例)*.

The answer posted by RuslanY will work (with some modifications to the rules slightly) however, after understanding more of the Azure portal and Web App configurations, it is not needed to host multiple sites within a single Web App (Its technically multiple web apps all sharing the resource plan you define, such as 2 instances of Standard Level 0 (S0))*.

对于今天的Azure服务产品,以下内容是正确的.创建新的Web应用程序时,您需要指定应用程序所属的应用程序服务计划".如果您有一个App Service计划(例如说带有2个实例的Standard),则您部署到该App Service计划的任何Web App都会与同一服务计划中的其他Web App共享这些资源,这意味着您无需支付额外费用来托管其他Web应用(如果它在同一个应用服务计划中).我假设每个Web应用程序都是其自己的资源集(可以,但不一定是).鉴于此,要完成我需要的工作,我只需为每个子域创建一个Web应用程序,然后将它们全部放入相同的App Service计划中即可.我现在托管了多个站点,而不是为每个站点支付2台服务器的费用(我想避免这种情况),而且我不必使用URL重写或HTTP处理程序.

As of today's Azure service offerings, the following is true. When you create a new Web App, you pecify the "App Service Plan" that the app falls into. If you have an App Service plan, lets say Standard with 2 instances, any Web App you deploy to that App Service plan shares those resources with other web apps in the same service plan, meaning you are not paying additional costs to host the additional web app if it is in the same App Service plan. I had assumed each web app was its own set of resources (it can be, but doesn't have to be). Given this, to accomplish what I need, I simply create a web app for each sub domain and place them all into the same App Service plan. I now am hosting multiple sites, not paying for 2 servers per site (what I wanted to avoid) and I don't have to use URL rewrites or HTTP Handlers.

我希望本文有助于其他人更好地了解Azure Web Apps的结构.据我所知,当前的在线文档并不清楚.

I hope this write-up helps others understand the structure of the Azure Web Apps a little bit better. The current online documentation, from what I can tell, doesn't make this exactly clear.

这篇关于将子域映射到虚拟目录Azure WebApp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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