Reputation: 12024
I have https public facing website hosted on linodes web hosting company. I created Cloudfront distribution for this website in my AWS account but it shows no activity as if nothing happening. Is there something I need to do to my website? If so what exactly I need to do?
Assume cloudfront url for my distrbution is abcxyz.cloudfront.net and my website is mysite.com which is https website.
Added:
By no activity I mean when I go to mysite.com, no data or logs generated in my cloudfront distribution which means content is coming from mysite.com and not from cloudfront cache. When I go to abcxyz.cloudfront.net, it shows content of mysite.com.
mysite.com is dynamic java website, html content is generated dynamically and user can interact with search feature on mysite.com. It is real estate website showing a lot of images of properties. All images urls are dynamically generated and looks like https: // www.mysite.com/photos/properties/5eef42ca5366c1485ad8693c/thumb/2500-feet-4.4-residential-for-sale-DSC_0001.JPG
I tried to add CNAME record (abcxyz.cloudfront.net) in CNAME DNS setting after login to Linode.com (my web hosting company) but it did not make any difference.
Its more than 2 weeks and still this cloudfront distribution has all metrics empty while mysite.com gets 2 or 3 visitors a day from around the world.
Upvotes: 3
Views: 1900
Reputation: 2992
Here's how the general process should work:
For the next user, steps 1, 2, 3 and 5 are run. Your site receives no more traffic.
Here's what you need for this setup
WWW
@
@ is the apex domain, which is the tricky part if you're not using aws's route53
@ only accepts A records, which you don't have for your cloudfront endpoint.
@ if you are using Route53 aws provides you with an ALIAS CNAME, which solves this dilema
if you are not using Route53, things get more complicated. You will have to find a way (either a hosted service or third party) that will let you point @.example.com to their IP, and redirect to www.example.com
you could have a static nginx rule that only redirects to www.example.com
server {
server_name example.com;
return 301 $scheme://www.example.com$request_uri;
}
That won't solve it for everyone, there are a few cases where people also use a CDN distribution as shield from the internet, which is could be called a WAF (web application firewall) and is supposed to keep you nice and hidden from internet monsters and in some cases as cloudfront + aws can provide you with some additional protection, traffic filtering etc. Giving up your server's IP for the apex domain, kind of violates that approach.
Now, you're all set for receiving traffic. And defining rules! Which is the fun part.
To be continued
Upvotes: 1
Reputation: 4377
I decided to delete my original answer and give you a step by step of what to do based on what I just did. I created two identical web pages, called fast.html and slow.html; the only thing they do is load 9 very big images, which I got from here https://effigis.com/en/solutions/satellite-images/satellite-image-samples/, totaling 335 Megabytes. The slow.html web page will load the images from the images directory on my machine. The fast.html web page will load the images from the CloudFrond distribution, which in turn gets the images from an S3 bucket to which I upload the images. So, step by step, here it is.
Create an S3 bucket called cf-big-images and inside the bucket create a folder called images
Upload the images to the bucket. I copied them from the images folder in the root of my Apache web server with the command aws s3 cp . s3://cf-big-images/images --recursive
Go into the images folder in the S3 bucket and make them public; this is set readonly for the public.
In CloudFront create a distribution. You only need to fill the field "Origin Domain Name". Click the field and you will see your S3 bucket there "cf-big-images.s3.amazonaws.com"; select it. [Note: I had this wrong on my original message]
That's it. Click on "Create Distribution" and wait. It takes quite a bit.
Change the fast.html web page. On my slow.html page I had:
<img src="images/Img15.jpg"> <img src="images/Img16.jpg"> <img src="images/Img17.jpg"> <img src="images/Img18.jpg"> <img src="images/Img34.jpg"> <img src="images/Img41.jpg"> <img src="images/Img48.jpg"> <img src="images/Img58.jpg"> <img src="images/Img100.tif">
On the fast.html web page I have:
<img src="https://d1pqzepyfmpq4.cloudfront.net/images/Img15.jpg"> <img src="https://d1pqzepyfmpq4.cloudfront.net/images/Img16.jpg"> <img src="https://d1pqzepyfmpq4.cloudfront.net/images/Img17.jpg"> <img src="https://d1pqzepyfmpq4.cloudfront.net/images/Img18.jpg"> <img src="https://d1pqzepyfmpq4.cloudfront.net/images/Img34.jpg"> <img src="https://d1pqzepyfmpq4.cloudfront.net/images/Img41.jpg"> <img src="https://d1pqzepyfmpq4.cloudfront.net/images/Img48.jpg"> <img src="https://d1pqzepyfmpq4.cloudfront.net/images/Img58.jpg"> <img src="https://d1pqzepyfmpq4.cloudfront.net/images/Img100.tif">
Hopefully it makes sense now.
Upvotes: 6
Reputation: 629
You can only do this if the hosting company gives you permission for DNS management.(if yes, then you can do that).Check your real server URL. (Or in DNS where your domain is mapped) Once you have that value, you need to try to create a Cloudfront distribution with that origin. and mapped the domain to Cloudfront url.
Or you can move to DNS management to Route 53. You have to create multiple records in route 53 records. Let me explain a bit.
Thanks
Ashish
Upvotes: 0