nginxinc / nginx-s3-gateway

NGINX S3 Caching Gateway
Apache License 2.0
515 stars 127 forks source link

Fix issue where bucket name is appended twice on path-style index page requests #230

Open 4141done opened 6 months ago

4141done commented 6 months ago

What

Aims to fix https://github.com/nginxinc/nginx-s3-gateway/issues/210

The gateway has a feature that allows serving of the base index page that lists files in the directory if no index.html exists in the requested folder. In order to do this it performs a test request against <path>/ index.html to check for an existing index page.

For path-style URIs where the bucket name must be provided, this resulted in the bucket name being prepended to the request twice.

For more details on the presentation and required solution, please see the issue.

Fix

I wanted to keep s3uri in charge of the behavior here, so chose to add an options parameter to it with the option preserveBasePath so that we can ask it to do its other work, but give back a path without anything prepended. In the future this object could be used to offer control over other operations