如何将带有前端SPA的Azure CDN和带有.Net Core WebApi的Azure WebApp配置到同一自定义域? [英] How to configure Azure CDN with front-end SPA and Azure WebApp with .Net Core WebApi to same custom domain?

查看:84
本文介绍了如何将带有前端SPA的Azure CDN和带有.Net Core WebApi的Azure WebApp配置到同一自定义域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将 https://example.com 作为已设​​置的Azure CDN的自定义域,并 https://example.com/api 作为其余api端点,以捕获来自我的所有调用SPA到提供数据的后端.Net Core Web API.

I would like to have https://example.com as the custom domain for the Azure CDN I have setup, and https://example.com/api as the rest api endpoint to catch all of the calls from my SPA to the back-end .Net Core Web API providing the data.

如何在App Service上设置自定义域来提供 https://example.com/api并为Azure CDN使用相同的自定义域来服务所有前端SPA网页?

How can I setup a custom domain on an App Service to serve the https://example.com/api and use the same custom domain for the Azure CDN to serve all of the front-end SPA web pages?

现在,我仅为App Service配置了自定义域,但是我想将前端SPA移至Azure CDN,以为Web API释放尽可能多的资源.

Right now, I have the custom domain configured for the App Service only, but I would like to move the front-end SPA to an Azure CDN to free up as many resources as possible for the Web API.

预先感谢您,任何方向将不胜感激.

Thank you in advance, any direction would be greatly appreciated.

推荐答案

您可以引入其他资源,例如 Azure前门可以充当代理并将CDN和您的App Service都隐藏在单个域后.

You can introduce another resource like Azure Front Door that can act as a proxy and hides both the CDN and your App Service behind a single domain.

Front Door允许您配置路由规则,以便将/api的请求路由到App Service,将静态资产的请求路由到CDN.

Front Door allows you to configure routing rules so that requests for /api get routed to the App Service and requests for static assets get routed to the CDN.

然后您可以将DNS CNAME设置为前门,所有请求都将发送到前门,而不是直接发送到CDN或您的应用程序服务.

You can then set your DNS CNAME to Front Door and all requests will be sent there rather than directly to the CDN or your App Service.

这为您提供了无需担心CORS的优势,因为从外部角度来看,所有内容都来自同一域.

This gives you the advantage of not needing to worry about CORS, because from an outside perspective everything is coming from the same domain.

它还具有其他优点,例如允许您配置请求限制,SSL终止和全局负载平衡等.

It also has additional benefits like allowing you to configure request throttling, SSL termination and global load balancing to name a few.

这篇关于如何将带有前端SPA的Azure CDN和带有.Net Core WebApi的Azure WebApp配置到同一自定义域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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