Skip to content

Commit

Permalink
configurable S3_OBJECT_PREFIX env var preprended to object paths
Browse files Browse the repository at this point in the history
  • Loading branch information
hoffmanr-cshs committed Dec 7, 2023
1 parent a95a6f3 commit 4ee95a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
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
}

// 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

0 comments on commit 4ee95a1

Please sign in to comment.