How to load part of section directly from Akamai to AWS S3 without requesting the origin server? - amazon-s3

I have one website, which is deployed on AWS instance and we have Akamai CDN. We are storing data in S3. We have few modules which do not require any processing from the web server and that can be directly served because those are pure static files say (RSS). Is there any way to load some links directly from Akamai to S3 without requesting the origin server?
For example, http://www.example.com/rss/1000.rss, can this /rss/* directly be configured in Akamai luna to load it from relevant S3 URL?
We tried sitefailover but it does not support the non property URLs Host names.

Create a new rule in Property Manager.
Add a match criteria, for /rss/*.
Add an Origin Server behavior.
Notes:
Set the Forward Host Header to Origin Hostname.
Set the Origin Server Hostname to a hostname that maps to your S3 bucket (replace yourbucket).
Make sure the files in the S3 bucket are publicly readable (public-read ACL).

Related

Configure Cloudfront with multiple s3 origins using different domains

How can I configure a Cloudfront distribution to use multiple s3 origins with same hierarchy but using different domain names?
Currently I have a Cloudfront distribution with a distribution domain name for example xyz.cloudfront.net.
The distribution has been configured to use an alternate domain e.g. assets.example.com and to serve content using that domain I've added cname record in my DNS management console that maps assets.example.com to xyz.cloudfront.net.
Now this set up works fine when serving content from a single s3 origin as i can call something like assets.example.com/images/my-image.png
However I want to configure 3 s3 origins as follows which have identical hierarchies i.e. they all have an images folder:
dev-bucket.s3.eu-west-2.amazonaws.com
test-bucket.s3.eu-west-2.amazonaws.com
live-bucket.s3.eu-west-2.amazonaws.com
If I've configured assets.example.com to map to the distribution xyz.cloudfront.net, how is cloudfront going to know which origin to serve from?
basically if im running the dev website i want cloudfront to serve content from the dev origin and if im running the test site then i want it to serve using the test origin.
The only way i can see how can i achieve this is creating 3 different cloud front distribution for each environment and map different domains to the distribution e.g. assets-dev.example.com, assets-test.example.com and assets.example.com for the live site.
Any advise appreciated.

Hosting multiple S3 origins under one CloudFront distribution

Is it possible to host multiple S3 origins under the same CloudFront distribution? Let's say I have bucket A and bucket B which both host static websites--could I add them both as origins to a distribution, and specify a path e.g. /alternate for the origin from bucket B so that visiting http://<distribution>/ took you to the website hosted by bucket A and visiting http://<distribution>/alternate brought you to the one hosted by bucket B? From what I've read so far it seems possible to have multiple origins, not necessarily multiple S3 origins.
You can add multiple S3 origins to a CloudFront distribution
However, behaviors are locked to a specific origin. Behavior controls the path. So, if /static is used by Origin A/S3 A, you can't have /static go to /Origin B/S3 B
Someone suggested using multiple CloudFronts with the same CNAME. That does not work either. CloudFront will not allow the same CNAME to be used in multiple distributions.
Academically speaking, this may be possible through LambdaEdge or some other external process that is checking S3 A, and if it is unavailable (say - under maintenance while new code being pushed), it can go and update CF Behavior for /static to Origin B/S3 B.
I wish AWS came up with a more elegant solution to this use case. Like allowing same CNAME in multiple distributions, or providing some kind of R53 integration with S3 buckets (never tried putting two different S3 buckets behind R53 .. probably will not work because the host header would change)
You can attach a Lambda function as a trigger to intercept CloudFront's routing. The implementation is quite involved; but would permit your specific use case.
Example Implementation:
https://aws.amazon.com/blogs/networking-and-content-delivery/dynamically-route-viewer-requests-to-any-origin-using-lambdaedge/
Lambda#Edge:
https://docs.aws.amazon.com/lambda/latest/dg/lambda-edge.html

How can I host my website on an EC2 Server using Apache but host my images on S3 under the same sub domain?

So I have my website hosted on an EC2 server running apache. All works fine and well.
The issue I'm having is that I want my images hosted on S3 (and possibly cached on CloudFront), not on my EC2 server, but want both accessible under the same domain/subdomain.
For example say my website is www.helloworld.com. I want my images to be accessible at www.helloworld.com/images/foobar.png. I want foobar.png to be hosted on S3 and not each one of my EC2 servers though. How can I go about doing this?
Is there and configuration I can do in the AWS console or are there any rewrite rules I can use in Apache? I know I could always just set up a controller that will download the images from S3 and forward them to the user, but this seems wrong to me.
For that you need to put a load-balancer/proxy in front to intercept all requests and dispatch accordingly. That may not be a bad idea anyway (for availability reasons), but a separate host name for images should not be a problem, either (it's not like users will have to see or type those URL).
Using CloudFront, you can have CloudFront receive the initial requests, then based on the path, forward the request to either your EC2 instance or to your S3 bucket.
For example, you could setup the following:
A CloudFront behaviour that upon a path under /images/ would use an S3 origin, and
A default (for everything else) would go to your EC2 instance origin.

Hosting dynamic website in Amazon server

I am working on a project where we are hosting our files(only uploaded by the user) in S3 Amazon server. Now the problem is the contents hosted with amazon is loading fastly. But the JS, CSS and CSS images(Very small images) which hosted in our server is taking too much time to load. Is there anyway to host our entire dynamic website to Amazon S3 and is it possible to configure the DNS to amazon?
Host your static files to S3 as well.
Create a bucket named static.yourcompany.com
CName the bucket URL as static.yourcomapany.com
In your webpages, use absolute path for CSS, JS, images with base URL as http://static.yourcompany.com
You may want to leverage tools like JetS3t for syncing the files with the latest changes.
Refer:
How to alias your subdomain with S3
JetS3t Docs
Virtual Hosting of Buckets
Host Your Static Website on S3
You can also read this blog, the author has described the process in a very detailed manner
http://geekospace.com/hosting-static-web-sites-in-aws-simple-storage-service/
For the dynamic part of your website look into http://aws.amazon.com/elasticbeanstalk/ but route 53 is essentially a way to configure DNS to amazon. http://docs.aws.amazon.com/AmazonS3/latest/dev/website-hosting-custom-domain-walkthrough.html

Using amazon s3, upload files using their servers but URL should appear to be from mine

Is it possible to upload files to amazon S3, using their servers (i.e. my server shouldn't be used in the upload process)?
I also want the URL to appear to be uploading to my server, is this possible?
Look here for instructions on how to setup your CNAME record so that one of your subdomains can be an alias for an Amazon S3 bucket.
Depending on your needs, you might not want "s3.amazonaws.com" to appear on your web site or service. For example, if you host your web site's images on Amazon S3, you might prefer http://images.johnsmith.net/ to http://johnsmith-images.s3.amazonaws.com/