简体   繁体   English

Azure云服务映射端口

[英]Azure Cloud Service mapping ports

I am using Azure Cloud Service and it packs two Roles: ASP.net MVC and ASP.net Web API projects. 我正在使用Azure云服务,它包含两个角色:ASP.net MVC和ASP.net Web API项目。 My MVC project uses ports 80 (for standard http protocol) and 443 (for https). 我的MVC项目使用端口80(用于标准http协议)和443(用于https)。 And my API project is using 8080 (http) and 8443 (https). 我的API项目使用的是8080(http)和8443(https)。

What I would like to do is to assign 8080,8443 and 443 to my API project, and to my MVC project keep 80, and assign some other port for https (for example 8444). 我想做的是将8080,8443和443分配给我的API项目,并将我的MVC项目保留80,并为https分配其他端口(例如8444)。

What I did is edited Endpoints under Roles' properties (as described above), and it worked, kind of. 我所做的是在“角色”属性下编辑了“端点”(如上所述),并且确实可行。

What is troubling me still is that when in a browser I enter https://mypage.com I am taken to my API page and not my MVC web page. 仍然令我困扰的是,在浏览器中输入https://mypage.com时,我被带到我的API页面,而不是我的MVC网页。 So how can I fix this (meaning that I want both my MVC and API projects to be accessible trough port 443) Could having https://api.mypage.com for my API project fix this? 那么,如何解决此问题(意味着我想同时通过端口443访问我的MVC和API项目)能否为我的API项目设置https://api.mypage.com If yes how can I configure my DNS (which is on GoDaddy) and Cloud Service to support https://api.mypage.com ? 如果是,我如何配置我的DNS(位于GoDaddy上)和云服务以支持https://api.mypage.com

Application Gateway can do the routing for you - Application Gateway可以为您完成路由-

You'll have 80 and 443/TCP for the outside world and then map that based on URL/subdomain to custom ports back to your WebRoles. 您将拥有80和443 / TCP用于外部世界,然后将基于URL /子域的映射到自定义端口,再返回到WebRoles。

Eg 例如

    example.com ---> 8080/TCP and 8443/TCP
api.example.com ---> 8081/TCP and 8444/TCP

More on that here: https://docs.microsoft.com/en-us/azure/application-gateway/application-gateway-multi-site-overview 此处的更多信息: https : //docs.microsoft.com/zh-cn/azure/application-gateway/application-gateway-multi-site-overview

A pair of varnish or nginx boxes will pretty much have the same result with the added benefit of caching things along the way. 一对清漆盒或nginx盒将具有几乎相同的结果,并具有沿途缓存内容的额外好处。 Downside is that you'll have to do it in IaaS and that's the opposite of an elegant weapon for a more civilized age... 缺点是您必须在IaaS中执行此操作,这与在更文明的时代使用优雅武器相反。

Sample config for varnish : Configure multiple sites with Varnish 清漆的样本配置: 清漆 配置多个站点

EDIT 编辑

Actually you COULD do it in PaaS on App Service with Docker containers: https://docs.microsoft.com/en-us/azure/app-service-web/app-service-linux-using-custom-docker-image 实际上,您可以使用Docker容器在App Service上的PaaS中完成此操作: https : //docs.microsoft.com/zh-cn/azure/app-service-web/app-service-linux-using-custom-docker-image

You know what, maybe it's time to move those services over to App Service as two different Web Apps, each listening on its own subdomain. 您知道吗,也许是时候将这些服务作为两个不同的Web Apps移至App Service了,每个Web App侦听自己的子域。 If you don't need elevation and you don't do messy things like write to registry you should be fine and you could drop a locomotive-worth of complexity straight away. 如果您不需要海拔并且不做诸如写注册表这样的麻烦事情 ,那应该没问题,您可以立即放弃机车价值的复杂性。

It's a crazy time to be alive. 这是活着的疯狂时刻。

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

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