Skip to content

Commit

Permalink
docs, add s3_style config
Browse files Browse the repository at this point in the history
  • Loading branch information
4141done committed Apr 23, 2024
1 parent cdd150d commit 05ba58b
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 4 deletions.
3 changes: 2 additions & 1 deletion common/docker-entrypoint.d/00-check-for-required-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ set -e

failed=0

required=("S3_BUCKET_NAME" "S3_SERVER" "S3_SERVER_PORT" "S3_SERVER_PROTO"
required=("S3_SERVICE" "S3_BUCKET_NAME" "S3_SERVER" "S3_SERVER_PORT" "S3_SERVER_PROTO"
"S3_REGION" "S3_STYLE" "ALLOW_DIRECTORY_LIST" "AWS_SIGS_VERSION"
"CORS_ENABLED")

Expand Down Expand Up @@ -122,6 +122,7 @@ if [ $failed -gt 0 ]; then
fi

echo "S3 Backend Environment"
echo "Service: ${S3_SERVICE}"
echo "Access Key ID: ${AWS_ACCESS_KEY_ID}"
echo "Origin: ${S3_SERVER_PROTO}://${S3_BUCKET_NAME}.${S3_SERVER}:${S3_SERVER_PORT}"
echo "Region: ${S3_REGION}"
Expand Down
3 changes: 2 additions & 1 deletion common/etc/nginx/include/s3gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ _requireEnvVars('S3_SERVER_PORT');
_requireEnvVars('S3_REGION');
_requireEnvVars('AWS_SIGS_VERSION');
_requireEnvVars('S3_STYLE');
_requireEnvVars('S3_SERVICE');


/**
Expand Down Expand Up @@ -86,7 +87,7 @@ const INDEX_PAGE = "index.html";
* Constant defining the service requests are being signed for.
* @type {string}
*/
const SERVICE = 's3express';
const SERVICE = process.env['S3_SERVICE'];

/**
* Transform the headers returned from S3 such that there isn't information
Expand Down
1 change: 1 addition & 0 deletions common/etc/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ env S3_REGION;
env AWS_SIGS_VERSION;
env DEBUG;
env S3_STYLE;
env S3_SERVICE;
env ALLOW_DIRECTORY_LIST;
env PROVIDE_INDEX_PAGE;
env APPEND_SLASH_FOR_POSSIBLE_DIRECTORY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ proxy_set_header Authorization $s3auth;
proxy_set_header X-Amz-Security-Token $awsSessionToken;

# We set the host as the bucket name to inform the S3 API of the bucket
proxy_set_header Host $s3_host_hdr;
proxy_set_header Host $s3_host;

# Use keep alive connections in order to improve performance
proxy_http_version 1.1;
Expand Down
1 change: 1 addition & 0 deletions deployments/s3_express/settings.s3express.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ S3_SERVER_PORT=443
S3_SERVER_PROTO=https
S3_REGION=us-west-2
S3_STYLE=virtual
S3_SERVICE=s3express
DEBUG=true
AWS_SIGS_VERSION=4
ALLOW_DIRECTORY_LIST=false
Expand Down
3 changes: 3 additions & 0 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ running as a Container or as a Systemd service.
| `S3_SERVER_PROTO` | Yes | `http`, `https` | | Protocol to used connect to S3 server |
| `S3_SERVER` | Yes | | | S3 host to connect to |
| `S3_STYLE` | Yes | `virtual`, `path`, `default` | `default` | The S3 host/path method. <li>`virtual` is the method that that uses DNS-style bucket+hostname:port. This is the `default` value. <li>`path` is a method that appends the bucket name as the first directory in the URI's path. This method is used by many S3 compatible services. <br/><br/>See this [AWS blog article](https://aws.amazon.com/blogs/aws/amazon-s3-path-deprecation-plan-the-rest-of-the-story/) for further information. |

| `S3_SERVICE` | Yes |`s3`, `s3express` | `s3` | Configures the gateway to interface with either normal S3 buckets or S3 Express One Zone |

| `DEBUG` | No | `true`, `false` | `false` | Flag enabling AWS signatures debug output |
| `APPEND_SLASH_FOR_POSSIBLE_DIRECTORY` | No | `true`, `false` | `false` | Flag enabling the return a 302 with a `/` appended to the path. This is independent of the behavior selected in `ALLOW_DIRECTORY_LIST` or `PROVIDE_INDEX_PAGE`. |
| `DIRECTORY_LISTING_PATH_PREFIX` | No | | | In `ALLOW_DIRECTORY_LIST=true` mode [adds defined prefix to links](#configuring-directory-listing) |
Expand Down
1 change: 1 addition & 0 deletions settings.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ S3_SERVER_PORT=443
S3_SERVER_PROTO=https
S3_REGION=us-east-1
S3_STYLE=virtual
S3_SERVICE=s3
DEBUG=false
AWS_SIGS_VERSION=4
ALLOW_DIRECTORY_LIST=false
Expand Down
5 changes: 4 additions & 1 deletion standalone_ubuntu_oss_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fi

failed=0

required=("S3_BUCKET_NAME" "S3_SERVER" "S3_SERVER_PORT" "S3_SERVER_PROTO"
required=("S3_SERVICE" "S3_BUCKET_NAME" "S3_SERVER" "S3_SERVER_PORT" "S3_SERVER_PROTO"
"S3_REGION" "S3_STYLE" "ALLOW_DIRECTORY_LIST" "AWS_SIGS_VERSION")

if [ ! -z ${AWS_CONTAINER_CREDENTIALS_RELATIVE_URI+x} ]; then
Expand Down Expand Up @@ -162,6 +162,8 @@ S3_SERVER_PROTO=${S3_SERVER_PROTO}
S3_SERVER=${S3_SERVER}
# The S3 host/path method - 'virtual', 'path' or 'default'
S3_STYLE=${S3_STYLE:-'default'}
# Name of S3 service - 's3' or 's3express'
S3_SERVICE=${S3_SERVICE:-'s3'}
# Flag (true/false) enabling AWS signatures debug output (default: false)
DEBUG=${DEBUG:-'false'}
# Cache size limit
Expand Down Expand Up @@ -346,6 +348,7 @@ env S3_REGION;
env AWS_SIGS_VERSION;
env DEBUG;
env S3_STYLE;
env S3_SERVICE;
env ALLOW_DIRECTORY_LIST;
events {
Expand Down
4 changes: 4 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ runUnitTestWithOutSessionToken() {
--workdir /var/tmp \
-e "DEBUG=true" \
-e "S3_STYLE=virtual" \
-e "S3_SERVICE=s3" \
-e "AWS_ACCESS_KEY_ID=unit_test" \
-e "AWS_SECRET_ACCESS_KEY=unit_test" \
-e "S3_BUCKET_NAME=unit_test" \
Expand All @@ -370,6 +371,7 @@ runUnitTestWithOutSessionToken() {
--workdir /var/tmp \
-e "DEBUG=true" \
-e "S3_STYLE=virtual" \
-e "S3_SERVICE=s3" \
-e "AWS_ACCESS_KEY_ID=unit_test" \
-e "AWS_SECRET_ACCESS_KEY=unit_test" \
-e "S3_BUCKET_NAME=unit_test" \
Expand All @@ -396,6 +398,7 @@ runUnitTestWithSessionToken() {
--workdir /var/tmp \
-e "DEBUG=true" \
-e "S3_STYLE=virtual" \
-e "S3_SERVICE=s3" \
-e "AWS_ACCESS_KEY_ID=unit_test" \
-e "AWS_SECRET_ACCESS_KEY=unit_test" \
-e "AWS_SESSION_TOKEN=unit_test" \
Expand All @@ -416,6 +419,7 @@ runUnitTestWithSessionToken() {
--workdir /var/tmp \
-e "DEBUG=true" \
-e "S3_STYLE=virtual" \
-e "S3_SERVICE=s3" \
-e "AWS_ACCESS_KEY_ID=unit_test" \
-e "AWS_SECRET_ACCESS_KEY=unit_test" \
-e "AWS_SESSION_TOKEN=unit_test" \
Expand Down
1 change: 1 addition & 0 deletions test/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ services:
S3_REGION: "us-east-1"
DEBUG: "true"
S3_STYLE: "virtual"
S3_SERVICE: "s3"
ALLOW_DIRECTORY_LIST:
PROVIDE_INDEX_PAGE:
APPEND_SLASH_FOR_POSSIBLE_DIRECTORY:
Expand Down

0 comments on commit 05ba58b

Please sign in to comment.