英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论