Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have some static files sitting in an S3 bucket that I want to serve up from my nginx server. Basically, if a user goes to I want to serve them up a file from the S3 bucket. What's the best way to go about doing this?

share|improve this question
Did you consider perhaps just using a CNAME record? That way you could just use something like (the bucket has to be named the same). (ErikA beat me by a few seconds on this one) – Sašo May 29 '12 at 15:13
up vote 7 down vote accepted

Why bring nginx into the mix? Just serve the file up to the user's browser directly out of S3.

To do this, ensure that the ACL on your S3 bucket allows read access from anonymous users. The URLs to your files there are as follows:<bucket_name>/<file_name>

You can also create a CNAME record to serve S3 files from your own domain. Keep in mind that the bucket name has to be identical to the domain you'll be using (i.e. - see S3 documentation for more info on that.

share|improve this answer
I kind of wanted to make it look like it was coming from my server, but I guess serving it up directly from S3 won't be so bad. And it will reduce load on my server. – Kurtis Nusbaum May 29 '12 at 17:43
@KurtisNusbaum - Appearances are over-rated. 99.99999% of users don't know nor care where webpage assets come from. You know what isn't over-rated? Speed and reliability, both of which will increase by pulling the files directly from S3. :) – EEAA May 29 '12 at 17:47
You know what, you're right. Well said. I guess my only question then would be access control (beyond the simple "this is public" and "this is private"). But that's a new question to ask :) – Kurtis Nusbaum May 29 '12 at 22:40
@ErikA The speed gain isn't really that noticeable and if the DNS server goes down, the main site would be affected either way. However, with a CNAME record, you're putting those few less bytes of strain on the server from the shorter url on embedded or linked content (Well, they do add up! :) ), and there isn't any need to change the actual website if you decide to move from S3 to a different service. The miniscule speed loss is worth it, IMO. – Sašo May 29 '12 at 23:01
@ErikA - I disagree that using S3 will improve normal performance. Average reposne time for s3 can approach 800ms (you can serve yourself much faster than this). It was not intended as a CDN, rather a storage mechanism (Cloudfront is the CDN offering). Reliability will be better of course, as will relative performance at high scales. – UpTheCreek Sep 19 '12 at 7:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.