nginx-s3-gateway
nginx-s3-gateway copied to clipboard
Path style breaks fetching INDEX_PAGE
loadContent will always attempt fetching the INDEX_PAGE by building the URI path using s3uri().
When using S3_STYLE = 'path', this will prepend the URI path with the S3 bucket. However, the fetch is made against nginx itself, meaning the URI path will always be incorrect for the requested index.
To Reproduce
Set the following variables:
ALLOW_DIRECTORY_LIST=true
PROVIDE_INDEX_PAGE=true
S3_STYLE=path
Expected behavior
Incorrect URI currently being built: http://127.0.0.1/<bucket_name>/<request_path>/<INDEX_PAGE>
Expected URI: http://127.0.0.1/<request_path>/<INDEX_PAGE>
Environments Tested
master@c687663ghcr.io/nginxinc/nginx-s3-gateway/nginx-oss-s3-gateway:latest- Backends: AWS, Ceph, OpenStack Swift
Workaround
I would submit a PR but I'm not sure which direction would be preferred by the project to go about building the URI path. However, here's a quick fix to demonstrate the issue:
From
const uri = s3uri(r);
To
let uri;
if (S3_STYLE === 'path') {
uri = `${r.uri}${INDEX_PAGE}`;
} else {
uri = s3uri(r);
}