- Newest
- Most votes
- Most comments
Hello Mohamad,
In my opinion, the most straightforward way to log user IP locations is by leveraging Amazon CloudFront. You will have to set up CloudFront as your CDN infront of your EC2 application, this would allow user request to route through the CloudFront domain instead of directly to your EC2 instance. CloudFront will be handling the logging of user's IP without adding any extra load to your EC2 instances.
To start logging your user request on CloudFront you will have to:
- Enable logging on CloudFront
- Link an S3 bucket where you want the logs to be stored.
After you have these set up CloudFront will automatically log user requests which includes the user's IP and the location of the CloudFront edge server that handles the request. Once the logs are stored in your s3 bucket, you can use Amazon Athena to query and analyze the data(if needed).
If you think my response answers your question please select this as accepted answer cheers!
Relevant content
- AWS OFFICIALUpdated 3 years ago
