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

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

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.

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.

AWS - Hosting Elastic Beanstalk + S3 behind ELB

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.

Access an AWS EC2 instance from Amazon S3 bucket

I have a static website hosted in a Amazon S3 bucket. The website uses PouchDB (javascript) to get data from a (Bitnami) CouchDB hosted in a EC2 instance.
The EC2 instance's inbound rules is configured to allow traffic for SSH, HTTP, .. including CouchDB port, 5984.
I could open the (EC2 hosted) CouchDB (Fauxton) from a browser, able to create / modify stuff, but the javascript in static website from S3 is unable to access the EC2.
The PouchDB throws error 'Timed out'.
Do I need to configure any other stuff in EC2?
Thanks
S3 is a Simple Storage Service, can only be used to store data. Nothing runs on S3. The website you are serving from S3 runs on your local system. Configure EC2 instance to accept traffic from web i.e allow 0.0.0.0/0 in the security group.

Does aws has alternative nginx?

I tried to find alternative of nginx on aws, and found only route 53. Is it the same service or no?
Does aws has alternative nginx?
NGINX is a web server which can also be used as a reverse proxy, load balancer and HTTP cache (Wikipedia). It is software that runs on an operating system (eg Linux, Windows).
There is no equivalent provided by AWS. You can run NGINX on an Amazon EC2 instance.
The closest equivalents on AWS would be:
Using Amazon S3 to serve static web content
Using Elastic Load Balancer to distribute traffic to multiple Amazon EC2 instances
Using Amazon CloudFront to cache content in multiple geographic locations
Amazon Route 53 is a DNS service for resolving domain names, which is not base NGINX functionality (although NGINX can handle virtual hosts, which overlaps a bit with DNS).