Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

S3 static website index document

I'm trying to upload my static website to my s3 bucket. I've managed to accomplish this. I've created my_bucket and then create a sub_bucket named test_folder and in that I uploaded all my css, html, js files.

It would look like this now:

 my_bucket/
  test_folder
    index.html

And I was able to view my index.html, horray! :D. But my question is in setting up the index document, since the index.html is located to a sub_bucket: test_folder/index.html when I try to save it, gave me The

IndexDocument Suffix is not well formed

Is it possible to link the index.html in a sub_bucket? If yes, how? If not, is there an alternative way to achieve this? I have here a screenshot link

like image 306
user2720708 Avatar asked Nov 28 '13 11:11

user2720708


People also ask

What is the index document file in an S3 hosted website?

An index document is a webpage that Amazon S3 returns when a request is made to the root of a website or any subfolder. For example, if a user enters http://www.example.com in the browser, the user is not requesting any specific page.

Can S3 host static website?

Amazon S3 enables static website hosting for your bucket. At the bottom of the page, under Static website hosting, you see the website endpoint for your bucket. Under Static website hosting, note the Endpoint. The Endpoint is the Amazon S3 website endpoint for your bucket.

Is this possible to run static websites from Amazon S3?

If you want to use HTTPS, you can use Amazon CloudFront to serve a static website hosted on Amazon S3. For more information, see How do I use CloudFront to serve HTTPS requests for my Amazon S3 bucket? To use HTTPS with a custom domain, see Configuring a static website using a custom domain registered with Route 53.


1 Answers

Though often used for different purposes, the index document was originally intended, conceptually, to be the "index" (directory listing or other content summary) of all of the files within each folder, so this configuration parameter specifies the index document to return for each folder in the entire bucket, if such a document exists within the folder... this isn't a single configuration "thing" for the bucket as a whole.

If your attempted configuration had been accepted by S3, it would have had the following impact, assuming a bucket name of "example.com":

browser address bar          file (object) actually returned
---------------------------  ------------------------------------
http://example.com           example.com/test/index.html
http://example.com/help      example.com/help/test/index.html
http://example.com/foo/test  example.com/foo/test/test/index.html

It seems very unlikely that this is what you actually intended.

However, but that is how index documents work... they are conceptually intended to be related to the other things at each level of the directory hierarchy, which of course could be the actual listing of files, or could be an "index" in a much more broad and vague and general sense of any "page," such as a landing page you want a visitor to see when they go to a specific "directory" on your site, which of course, in the modern web is not typically conceptualized as a "directory" but rather simply as a "page."

So the index document has to be immediately under the same / delimiter and can't contain an additional / within its own specification.

The index document for example.com has to be stored in example.com/index.html (assuming "index.html" is your chosen index filename) -- it has to be stored within the "directory" that it indexes, just like on a conventional web server, where, in some configurations, the web server will actually display a directory listing of files, with the "index" page replacing that directory listing in cases where the "index" page actually exists. Of course, S3 doesn't have default directory listing page functionality.

http://docs.aws.amazon.com/AmazonS3/latest/dev/IndexDocumentSupport.html

In contrast to the index document, the error document, if you configure it, is a global configuration that is used regardless of where, within the bucket, the 404 occurs, so slashes are supported in that entry. The AWS console prompts are light on hints as to the nature of the two entries, which are so different in their behavior that they arguably should be more separated, visually.


You'll note that "sub-bucket" isn't an actual term, for what you are describing, which is an object with delimiters in its key (path), which gives the appearance of being nested under a directory or folder.

For clarity, I have used the words "folder" and "directory" very casually all throughout this answer, with the conventional meaning... but for technical accuracy, I'll mention that S3 objects are not really stored internally in a hierarchical fashion "in directories." It appears this way, and for practical purposes, it works that way; however, it's actually the case that the / character, while close to being just another character in the object key, although it gets some special treatment as a delimiter because of its conventional use as a directory delimiter.Unlike some more conventional filesystems, the number of "files in each directory" does not pose any performance concern with S3 and doesn't need to be managed in the same way as is needed in a conventional filesystem when a large number of files exists, since S3 internally hashes the key ("path") of each object for its internal storage partitioning logic.

like image 99
Michael - sqlbot Avatar answered Oct 12 '22 22:10

Michael - sqlbot