Please read my previous article Understanding Amazon CloudFront
Note: CloudFront allows you to configure cache control and Time-To-Live (TTL) settings, giving you control over how long content is cached at the edge locations.
This allows you to balance the freshness of content with cache hit rates.
CloudFront has features similar to dynamic site acceleration, a method used to improve online content delivery.
CloudFront accelerates the delivery of dynamic content by moving it closer to the user to minimize internet hops involved in retrieving the content.
You create a CloudFront distribution to tell CloudFront where you want content to be delivered from, and the details about how to track and manage content delivery.
Please visit my GitHub Repository for S3 articles on various topics being updated on constant basis.
Let’s get started!
I have divided this article into 3 parts for understanding this process better.
1. Sign into AWS Management Console.
2. Launch two EC2 Instances
my-EC2 using Bash script.
3. Create a Target Group
4. Create an application Load Balancer.
5. Create the CloudFront Distribution.
6. Test the distribution.
- AWS user account with admin access, not a root account.
- Make sure you're in the N. Virginia (us-east-1) region
- Check the Allow SSH traffic from
- Check the Allow HTTP traffic from the internet.
- Check the Allow HTTPs traffic from the internet.
5. Under, User data: section, copy and paste the script to install Apache webserver and php and copy the php file from S3 bucket to the server path.
- user data
#!/bin/bash # Switch to the superuser to execute commands with elevated privileges sudo su # Update the package repository and install Apache web server (httpd) and PHP yum update -y yum install httpd php -y # Start the Apache web server systemctl start httpd # Enable the Apache web server to start automatically on system boot systemctl enable httpd # Change the current directory to the web server's root directory cd /var/www/html/ # Download the sample PHP webpage to the web server's root directory wget https://s3.amazonaws.com/joshiawssolutions.com/index.php # Restart the Apache web server to apply the changes and serve the PHP webpage systemctl restart httpd
- 1. click on the 1st instance ID and copy the IPv4 Public IP of this instance.
http://<IPv4 public IP>/index.php http://220.127.116.11/index.php
- 2. click on the 2nd instance ID and copy the IPv4 Public IP of this instance.
http://<IPv4 public IP>/index.php http://18.104.22.168/index.php