You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Add new configuration option STRIP_LEADING_DIRECTORY_PATH. (#185)
Many thanks to https://github.com/elJosho for this contribution.
This will strip the leading directory from a request if configured. It's useful when you're trying to expose a bucket at a specific path on an ALB. For example, if I have an ALB rule that forwards all traffic from "www.mysite.com/mybucket" to the S3 gateway, and I want to request a file in the root of my bucket, "myfile.txt". Making a request to "www.mysite.com/mybucket/myfile.txt" will fail as the S3 gateway will look for the file inside a folder named "mybucket", rather than at the root of the bucket.
After this change, setting the new env var to
`STRIP_LEADING_DIRECTORY_PATH = /mybucket`
will send all requests to the root of the bucket.
---------
Co-authored-by: Josh Watt <josh.watt@moodys.com>
Copy file name to clipboardExpand all lines: docs/getting_started.md
+9-2Lines changed: 9 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,8 +39,8 @@ running as a Container or as a Systemd service.
39
39
|`JS_TRUSTED_CERT_PATH`| No ||| Enables the `js_fetch_trusted_certificate` directive when retrieving AWS credentials and sets the path (on the container) to the specified path |
40
40
|`HEADER_PREFIXES_TO_STRIP`| No ||| A list of HTTP header prefixes that exclude headers client responses. List should be specified in lower-case and a semicolon (;) should be used to as a deliminator between values. For example: `x-goog-;x-something-`|
41
41
|`CORS_ENABLED`| No |`true`, `false`|`false`| Flag that enables CORS headers on GET requests and enables pre-flight OPTIONS requests. If enabled, this will add CORS headers for "fully open" cross domain requests by default, meaning all domains are allowed, similar to the settings show in [this example](https://enable-cors.org/server_nginx.html). CORS settings can be fine-tuned by overwriting the [`cors.conf.template`](/common/etc/nginx/templates/gateway/cors.conf.template) file. |
42
-
|`CORS_ALLOWED_ORIGIN`| No ||| value to set to be returned from the CORS `Access-Control-Allow-Origin` header. This value is only used if CORS is enabled. (default: \*) |
43
-
42
+
| `CORS_ALLOWED_ORIGIN` | No | | | value to set to be returned from the CORS `Access-Control-Allow-Origin` header. This value is only used if CORS is enabled. (default: \*)
43
+
| `STRIP_LEADING_DIRECTORY_PATH` | No | | | Removes a portion of the path in the requested URL (if configured). Useful when deploying to an ALB under a folder (eg. www.mysite.com/somepath).
44
44
45
45
If you are using [AWS instance profile credentials](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2.html),
46
46
you will need to omit the `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` and `AWS_SESSION_TOKEN` variables from
@@ -104,6 +104,13 @@ It will also redirect `/some/path` to `/some/path/` when S3 returns 404 on
104
104
look like a possible directory, it must not start with a `.` and not have an
105
105
extension.
106
106
107
+
### Hosting a Bucket as a Subfolder on an ALB
108
+
109
+
The `STRIP_LEADING_DIRECTORY_PATH` environment variable allows one to host an
110
+
S3 bucket in a subfolder on an ALB. For example, if you wanted to expose the
111
+
root of a bucket under the path "www.mysite.com/somepath", you would set this
112
+
variable to "/somepath".
113
+
107
114
## Running as a Systemd Service
108
115
109
116
An [install script](/standalone_ubuntu_oss_install.sh) for the gateway shows
0 commit comments