Project

General

Profile

Bug #46241

rgw: website request without trailing slash should redirect with 302 Found

Added by Dan van der Ster almost 4 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
% Done:

0%

Source:
Community (dev)
Tags:
Backport:
nautilus
Regression:
No
Severity:
2 - major
Reviewed:
Affected Versions:
ceph-qa-suite:
rgw
Pull request ID:
Crash signature (v1):
Crash signature (v2):

Description

According to the AWS S3 doc [1]:

... the following URL, with a trailing slash, returns the photos/index.html index document.

http://bucket-name.s3-website.Region.amazonaws.com/photos/

However, if you exclude the trailing slash from the preceding URL, Amazon S3 first looks for an object photos in the bucket. If the photos object is not found, it searches for an index document, photos/index.html. If that document is found, Amazon S3 returns a 302 Found message and points to the photos/ key. For subsequent requests to photos/, Amazon S3 returns photos/index.html. If the index document is not found, Amazon S3 returns an error.

In rgw we have a different behaviour, namely that the request for key x will returns 200 OK with the contents of x/index.html immediately, with no redirection.

The consequence of this is that websites with relative links often don't work if key x is requested instead of x/

Here's an example. First I create a new empty website:

@aiadm99 ~> s3cmd mb s3://dvanders-w2
Bucket 's3://dvanders-w2/' created
@aiadm99 ~> s3cmd ws-create s3://dvanders-w2
Bucket 's3://dvanders-w2/': website configuration created.
@aiadm99 ~> s3cmd put -P index.html s3://dvanders-w2/subdir/index.html
upload: 'index.html' -> 's3://dvanders-w2/subdir/index.html'  [1 of 1]
 6 of 6   100% in    0s    90.46 B/s  done
Public URL of the object is: http://dvanders-w2.s3-fr-prevessin-1.cern.ch/subdir/index.html

Checking the behaviour:

~ $ curl http://s3-website-fr-prevessin-1.cern.ch/dvanders-w2/subdir/
hello
~ $ curl http://s3-website-fr-prevessin-1.cern.ch/dvanders-w2/subdir
hello
~ $ curl -I http://s3-website-fr-prevessin-1.cern.ch/dvanders-w2/subdir
HTTP/1.1 200 OK
Content-Length: 6
Bucket: dvanders-w2
...

[1] https://docs.aws.amazon.com/AmazonS3/latest/dev/IndexDocumentSupport.html#IndexDocumentsandFolders
[1] also "302 Found" here: https://docs.aws.amazon.com/AmazonS3/latest/dev/CustomErrorDocSupport.html

Also available in: Atom PDF