AWS - Hosting Elastic Beanstalk + S3 behind ELB - amazon-web-services

I have an Elastic Beanstalk instance serving a backend app running natively HTTP and an Angular app hosted on a S3 instance.
Now, I would like to put these on a single domain www.example.com, behind a SSL protected Load Balancer which will route the request internally by the URI, either to the backend (/api/) or angular app (/). For this I setup a Route53 DNS which I wired to the LB.
I don't see an option to route directly from LB to the S3 instance though. I've read that, I should create a CloudFront distribution for the angular app and specify the LB as the origin but after configuring CF distro, I don't see any option inside of the LB to connect it to the angular app. How should I approach it?

Routing should be handled on CloudFront not on load balancer in this case. You can create multiple behaviors in CloudFront, each pointing to a different origin. So you can choose default CloudFront behavior(*) to point to your s3 bucket and create second behavior that is used whenever URL contains /api to point to your load balancer origin.

Related

Connecting private load balancer to cloud front distribution?

I have a python flask application hosted on Elastic Beanstalk (Private Load Balancer).
I wanted to integrate Elastic Beanstalk with Cloudfront so that the Web application can be opened using cloudfront distribution.
How can i achieve this?
ALB must be public. From docs:
Although you can use a signed URL to distribute content from a custom origin, for CloudFront to access the custom origin, the origin must remain publicly accessible.

How to deploy a website and webservice in AWS using same domain name

We have to deploy Restful Webservice(API services) and static pages in the AWS environment.
Currently, our Webservice is hosted in EC2 instance with one ELB and Route53. Also, the static pages are deployed in the S3 bucket. The Webservice and Website, both should be in the same domain.
When the user calls "www.domain.com/" it should be routed to the S3 server. However the API calls (www.domain.com/api/**) should be routed to EC2 through ELB. Is there any way to
route API calls to ELB and website access calls to S3 using Route53?
or What is the best approach to resolve this?
Yes, you can deploy both using the same domain name. APIs should be deployed using api.domain.com and websites can deploy using domain.com. For that, you need to purchase an SSL certificate with a domain name and subdomain (eg: https://example.com and https://api.example.com) support and do the following.
Configure certificate in AWS ACM
Deploy your website in the S3 bucket with CloudFront
Deploy APIs in EC2 with the support of a Load balancer (ELB)
Configure Route53 and define two routes. Ie, create Records with 'A record type' in Route53 with ELB address and CloudFront address.
See sample deployment architecture

AWS replace EC2 with CloudFront

I have a domain dev-www.myexample.de hosted via AWS EC2 and a Load Balancer. I want to replace this configuration with an S3 bucket + CloudFront and keep same domain name.
The only possible way I could find was destroying my EC2 instance and Route 53 and then deploy my CloudFront and domain and this works fine.
However, I want to show a 503 page for all traffic that comes while my EC2 instance is down and before my CloudFront and S3 bucket are ready to use. Any idea how I can do that?
You can create your Amazon S3 bucket and Amazon CloudFront distribution before changing the DNS configuration. This gives you an opportunity to ensure that it is working correctly.
Then, you can change the Route 53 configuration to point to CloudFront instead of the Load Balancer. It will take some time for this change to propagate throughout the Internet, during which cached queries will continue to go to the Load Balancer but new DNS lookups will go to CloudFront. If you have the same content in both locations, there should not be a need to display any notice.
Please note that only static content can be served from Amazon S3, so if you had any back-end logic in your Amazon EC2 servers, it would not be possible to continue providing it with CloudFront + S3.

how can I use cloudfront with multiple beanstalk environments?

right now I have an app that runs on several beanstalk environments in different regions and use route53 geo location records for routing
I want to use cloudfront for these environments
Can I create a cloudfront for each environment and route to them with route53? Or can I create a single cloudfront and connect all of the beanstalks to it? Do I have to use cloudfront lambda to do something like this?
Can I create a cloudfront for each environment and route to them with route53?
CloudFront and Route53 don't relate to each other.
Route53 gives URL of an application (deployed to Beanstalk in this case) to end users. When users open this URL, they will see something rendered. This something uses resources. These resources can be stored in CloudFront CDN or can be stored in your application.
You can see that Route53 doesn't collaborate with CloudFront here.

AWS setup advice. EC2 + S3 - cloudfront in front?

I am configuring a system that consists of two parts. An ec2 instance to run a backend, and serve a few pages, as well as an s3 bucket to serve a react app, as well as some static assets.
Obviously, I need them both to be behind ssl, and at the same domain. Which of these architectures makes more sense:
cloudfront (handling ssl) -|-> elastic load balancer -> ec2 instance
|-> s3 bucket
ec2 instance (with nginx as rev. proxy handling ssl) -|-> local server
|-> s3 bucket
That is - a cloudfront instance handling ssl and routing requests to either ec2 (via a load balancer) or s3, depending on the path.
Or, the ec2 instance running an nginx reverse proxy handling ssl, and routing requests to either itself, or to s3, depending on the path