如何配置域名,如果前端在AWS Amplify上运行,后端在AWS Fargate上运行。

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

How to configure domain name if frontend running on aws amplify and backed running on AWS fargate

问题

我已经拥有一个域名,即test.com。

我已经使用ReactJS和Django创建了一个新的Web应用程序。

我已经在AWS Amplify上设置了ReactJS应用程序,并获得了公共AWS URL:front.aws.url.com。

我已经在AWS ECS Fargate上设置了Django应用程序,并通过ALB获得了公共AWS URL:backend.aws.url.com。

现在我想要使用我的已有域名,并将它们放在一个新的路径中。

例如:

“前端”将位于test.com/testing。

而“后端API”将被调用为test.com/testing/api/。

如何在AWS中实现这一点?

英文:

I have a domain name already i.e test.com

I have created a new web application using reactjs and django

I have Setup the reactjs application on AWS amplify and i got the public aws url. front.aws.url.com

I have Setup the django application on AWS ECS fargate and i got the public aws url through ALB as backend.aws.url.com

Now i want to use my already existing domain name and put these in a new path

eg:

frontend will be on test.com/testing

and backend apis are called at test.com/testing/api/

How can i do this in aws

答案1

得分: 2

前端将位于 test.com/testing

后端API将在 test.com/testing/api/ 调用

为了使它们都位于同一个域名下,但具有不同的路径,您需要在它们前面放置一个代理,用于处理不同路径到不同服务器的映射,并执行路径重写。在AWS中,您需要创建一个CloudFront分发,配置自定义域名,并配置多个源。

一般来说,使用前端和后端的多个子域名会更容易,也更加灵活,比如:

前端:test.com

后端:api.test.com

英文:

> frontend will be on test.com/testing
>
> and backend apis are called at test.com/testing/api/

In order to have them both on the same domain name, with different paths, you would have to place a proxy in front of them that handles the mapping of different paths to different servers, and also does path rewriting. In AWS you would have to create a CloudFront distribution, configure the custom domain name, and configure multiple origins.


It is generally much easier, and much more flexible, to use multiple subdomains for front-end and back-end, like:

frontend: test.com

backend: api.test.com

huangapple
  • 本文由 发表于 2023年4月10日 20:03:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/75976944.html
匿名

发表评论

匿名网友

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

确定