如何将带有前端 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?

查看:14
本文介绍了如何将带有前端 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.

如何在应用服务上设置自定义域以提供 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?

目前,我仅为应用服务配置了自定义域,但我想将前端 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 Front Door 可以充当代理并将 CDN 和您的应用服务隐藏在单个域后面.

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 请求路由到应用服务,并将静态资产请求路由到 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 设置为 Front Door,所有请求都将发送到那里,而不是直接发送到 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天全站免登陆