# Serving websites from S3

**URL:** <https://www.ruby-forum.com/t/serving-websites-from-s3/207132>\
**Category:** NGINX\
**Created:** [May 19, 2011, 12:40am UTC](https://www.ruby-forum.com/t/serving-websites-from-s3/207132 "2011-05-19T00:40:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [May 19, 2011, 12:40am UTC](https://www.ruby-forum.com/t/serving-websites-from-s3/207132/1 "2011-05-19T00:40:57Z")

</div>

Hi guys, I’ve tried to ask pretty much everywhere, but no solution until  
now. I’m quite sure I’m doing something wrong here, but to be honest I’m  
not able to catch it.

I’m rewriting urls from [test.foo.com](http://test.foo.com) to  
[bar.foo.com.s3.amazonaws.com/test](http://bar.foo.com.s3.amazonaws.com/test), and everything works like a charm. If  
I point the browser to [test.foo.com/index.html](http://test.foo.com/index.html) nginx serves my static  
website exactly as I want. The problem I’m facing now is that I’m not  
able to have nginx serve my index.html by default, while retrieving  
[test.foo.com/](http://test.foo.com/)

I’ve tried both try\_files and index so far, with no result. I’ve also  
tried to catch 404s and serve my index.html page (even though I guess  
this is a bad practice).

This is what I have right now:

> <https://gist.github.com/ngw/9a1ca5095392fb083f05>

Can someone help me? I’m a bit out of ideas.

What is really strange to me is that (real example)  
[http://test.stylej.am/](http://test.stylej.am/) answers with a 404, I really have no idea why  
try\_files doesn’t work… Maybe $url/index.html is not right and I  
should use another syntax?

ngw

---

<div class="post-metadata">

**Author:** ![Nicholas\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f17d59/32.png) [@Nicholas\_W](https://www.ruby-forum.com/u/Nicholas_W)\
**Post date:** [May 19, 2011, 11:17am UTC](https://www.ruby-forum.com/t/serving-websites-from-s3/207132/2 "2011-05-19T11:17:23Z")

</div>

On Wed, 2011-05-18 at 15:40 -0700, Nicholas W. wrote:

> retrieving [test.foo.com/](http://test.foo.com/)
> 
> Can someone help me? I’m a bit out of ideas.
> 
> What is really strange to me is that (real example)  
> [http://test.stylej.am/](http://test.stylej.am/) answers with a 404, I really have no idea why  
> try\_files doesn’t work… Maybe $url/index.html is not right and I  
> should use another syntax?

You know that Amazon added support for index files to S3?

> **[Typepad | Network Solutions](https://www.networksolutions.com/typepad?siteID=100&channelID=P99C100S653N0B5A1D0E0000V111)**

Try\_files does not work because it looks for acrual files on your file  
system, and thats not where S3 is! You can use two locations, one to  
match just / and one to match all other files.

Justin
