how to allow traffic from a static s3 website to an ec2 instance

0

I have a static website in an s3 bucket that communicates through port 3000 with a backend server in an ec2 instance, I need to deny all incoming traffic to the ec2 instance except traffic coming from the s3 bucket,

3 Answers
1

An s3 bucket can serve static files. It will not be able to connect to anything. It can’t process server side scripting like php and asp. It’s an object store not a full blown web server.

Do you mean the users browser will connect to the ec2 on port 3000 as the static content will be served to the browser and in turn the end user connects.

You can use Amazon S3 to host a static website. On a static website, individual webpages include static content. They might also contain client-side scripts.

By contrast, a dynamic website relies on server-side processing, including server-side scripts, such as PHP, JSP, or ASP.NET. Amazon S3 does not support server-side scripting, but AWS has other resources for hosting dynamic websites. To learn more about website hosting on AWS, see

profile picture
EXPERT
answered a year ago
  • This answer is not relevant at all

  • Of course it is. What’s being asked isn’t possible.

  • An s3 bucket can’t to connect to anything. It’s an object store.

  • I've upvoted this answer because someone downvoted it and i can't see why. Basically the question asked here isn't clear enough to know what's relevant and what's not - this answer raises some good questions. What does the OP mean "a static website in an s3 bucket that communicates through port 3000 with a backend server in an ec2 instance"? A better description of the architecture is needed. This could mean that there's a web server EC2 layer serving static S3 data, and it's this web server communicating with a backend server? Hard to tell.

0

I think you need to implement CORS on the EC2 instance assuming you are using HTTP to hit port 3000. You could also put both site behind CloudFront distributions and enable CORS there.

profile pictureAWS
EXPERT
kentrad
answered a year ago
-1

To allow traffic from a static S3 website to an EC2 instance, you can follow these steps: Configure the EC2 instance, obtain the public IP or domain of the EC2 instance, configure S3 bucket redirection, set up Route 53 (optional), test the setup, and ensure the necessary security measures are in place to protect the EC2 instance and control the traffic flow. These steps will ensure that traffic from the S3 website is properly redirected to the desired content on the EC2 instance. If you're looking for Custom Web Design, I recommend considering The Web Factory.https://www.thewebfactory.us/web-design-services

profile picture
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions