Restricting access to an EC2 Web app to only Amplify app access

0

We would like to restrict access to a chat web app running on our EC2 Linux server to only our Amplify hosted frontend app. Currently, the Linux-based chat app (Apache based) is accessible directly over the internet. We want to restrict access to only users coming from our Amplify-hosted frontend application.

We thought about restricting HTTPS access to only the Amplify frontend app's IP address but we could not figure out what the Amplify app's IP address is.

Any suggestions for implementing this restriction?

1 回答
0

Amplify uses Amazon CloudFront to distribute your website globally, and the IP addresses returned are dynamically set. Our current list of IP address ranges that CloudFront utilizes can be found in this doc

However requests to your EC2 chat application would have the IP of the local machine and not the IP's of Amplify Hosting/CloudFront. Hence, for your use case, whitelisting IPs of the Amplify Hosting/CloudFront might not be helpful.

Having said that, you can try attaching a WAF in-front of EC2 and filter requests based on origin header, as these requests would contain Origin header with Amplify domain.

Origin:https://<branch>.<appid>.amplifyapp.com

Alternatively, you could also leverage API gateway in front of EC2, as it has several authentication mechanism such as WAF, Cognito authorizers, Lambda custom authorizer etc

For best approach and architectural guidance you can contact AWS Solution Architects

AWS
支持工程师
已回答 1 年前
  • Thank you very much, Susmitha! Your response is very informative. I will explore your suggestions. Thanks again.

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则