AWS:使用Route 53管理Elastic Beanstalk API和CloudFront路由。

huangapple go评论52阅读模式
英文:

AWS : Manage Elastic Beanstalk API and CloudFront routes with Routes 53

问题

我想知道如何管理我的架构的路由。总结一下,我的架构由以下组成:

  • 在CloudFront CDN下公开的S3静态网站
  • 基于Django Rest和Python的Docker容器的Elastic Beanstalk API

通常情况下,我会在我的Route 53托管区域中插入新的记录,但我在这里的目标是拥有类似Nginx位置与proxy_pass的等效配置。例如,我希望有以下配置:

  • <my_dns_record>/api 指向我的Beanstalk API
  • <my_dns_record> 指向我的CloudFront上的静态网站

我考虑过使用API Gateway,但我不确定它是否真的是最佳的路由结构方式。

是否有人知道如何实现所需的行为?感谢您提前的帮助。

英文:

I wonder how to manage the routes of my architecture. To summarize, my architecture is composed of :

  • S3 static website exposed under CloudFront CDN
  • Elastic Beanstalk API (based on Docker container with Django Rest and Python)

I usually insert a new record to my hosted zone in my route 53 but my goal here is to have the equivalent of Nginx locations with proxy_pass. For example, I would have :

  • &lt;my_dns_record&gt;/api that target my Beanstalk API
  • &lt;my_dns_record&gt; that target my static website on my CloudFront

I thought about an API Gateway but I wonder if it's really the best way to structure the routing.

Does anyone have an idea how to achieve the desired behavior ?
Thank you in advance for your help.

答案1

得分: 1

如果我理解正确,您希望将多个应用程序(您的S3静态站点和您的Elastic Beanstalk应用程序)都提供在一个单一的域名下。Route53没有任何特殊功能来处理这个,因为它只是一个DNS服务,而您所说的是一个HTTP路径路由的事情。

您也不应该使用API Gateway来实现这个,因为这将把整个网站都置于API Gateway之后,而实际上只有您的API适合置于API Gateway之后。

我建议将Elastic Beanstalk API添加到CloudFront中,作为第二个源,并配置CloudFront将请求发送到Elastic Beanstalk源的/api路径。


另外,如果不考虑将所有内容都放在同一个域名下,您可以使用子域名api.yourdomain.com来为您的API服务。使用子域名来为不同的服务而不是路径路由更加灵活。

英文:

If I understand correctly, you want to have multiple apps (your S3 static site, and your Elastic Beanstalk app) served under a single domain. Route53 doesn't have any special features to handle this, since it is just a DNS service, and what you are talking about is an HTTP path routing thing.

You also shouldn't use API Gateway for this, as you would be placing your entire website behind an API Gateway when it is really only appropriate to have your API behind an API Gateway.

I would just add the Elastic Beanstalk API under CloudFront as well, as a second origin, and configure CloudFront to send requests at the /api path to the Elastic Beanstalk origin.


Alternatively, forget about having everything under the same domain, and use a subdomain api.yourdomain.com for your API. Using subdomains for your different services instead of path routing is a lot more flexible.

huangapple
  • 本文由 发表于 2023年2月14日 04:28:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/75440861.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定