Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to specify a prefix to be prepended to object paths #190

Merged
merged 4 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions common/etc/nginx/include/s3gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ const FOUR_O_FOUR_ON_EMPTY_BUCKET = utils.parseBoolean(process.env['FOUR_O_FOUR_
* @type {string}
* */
const S3_STYLE = process.env['S3_STYLE'];
/**
* Prefix to be prepended to all object names, allowing the serving of a
* subset of a bucket. Default ''.
* @type {string}
*/
const S3_OBJECT_PREFIX = process.env['S3_OBJECT_PREFIX'] || '';
/**
* Additional header prefixes to strip from the response before sending to the
* client. This is useful for removing headers that may contain sensitive
Expand Down Expand Up @@ -285,6 +291,10 @@ function s3uri(r) {
const basePath = s3BaseUri(r);
let path;

if (S3_OBJECT_PREFIX) {
uriPath = S3_OBJECT_PREFIX + uriPath
}
hoffmanr-cshs marked this conversation as resolved.
Show resolved Hide resolved

// Create query parameters only if directory listing is enabled.
if (ALLOW_LISTING && !utils.parseBoolean(r.variables.forIndexPage)) {
const queryParams = _s3DirQueryParams(uriPath, r.method);
Expand Down
1 change: 1 addition & 0 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ running as a Container or as a Systemd service.
| `AWS_SECRET_ACCESS_KEY` | Yes | | | Secret access key |
| `AWS_SESSION_TOKEN` | No | | | Session token. |
| `S3_BUCKET_NAME` | Yes | | | Name of S3 bucket to proxy requests to |
| `S3_OBJECT_PREFIX` | No | | | Prefix to prepend to all S3 object paths |
| `S3_REGION` | Yes | | | Region associated with API |
| `S3_SERVER_PORT` | Yes | | | SSL/TLS port to connect to |
| `S3_SERVER_PROTO` | Yes | `http`, `https` | | Protocol to used connect to S3 server |
Expand Down
Loading