Skip to content

Commit e2a7512

Browse files
shawnhankimdekobon
authored andcommitted
fix #90 for failure to start nginx.service
1 parent 5a54bb1 commit e2a7512

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

standalone_ubuntu_oss_install.sh

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ echo "Addressing Style: ${S3_STYLE}"
8181
echo "AWS Signatures Version: v${AWS_SIGS_VERSION}"
8282
echo "DNS Resolvers: ${DNS_RESOLVERS}"
8383
echo "Directory Listing Enabled: ${ALLOW_DIRECTORY_LIST}"
84+
echo "Proxy Caching Time for Valid Response: ${PROXY_CACHE_VALID_OK}"
85+
echo "Proxy Caching Time for Not Found Response: ${PROXY_CACHE_VALID_NOTFOUND}"
86+
echo "Proxy Caching Time for Forbidden Response: ${PROXY_CACHE_VALID_FORBIDDEN}"
87+
echo "CORS Enabled: ${CORS_ENABLED}"
8488

8589
set -o nounset # abort on unbound variable
8690

@@ -123,7 +127,7 @@ fi
123127

124128
echo "▶ Adding environment variables to NGINX configuration file: /etc/nginx/environment"
125129
cat > "/etc/nginx/environment" << EOF
126-
# Enables or disables directory listing for the S3 Gateway (1=enabled, 0=disabled)
130+
# Enables or disables directory listing for the S3 Gateway (true=enabled, false=disabled)
127131
ALLOW_DIRECTORY_LIST=${ALLOW_DIRECTORY_LIST}
128132
# AWS Authentication signature version (2=v2 authentication, 4=v4 authentication)
129133
AWS_SIGS_VERSION=${AWS_SIGS_VERSION}
@@ -141,8 +145,35 @@ S3_SERVER=${S3_SERVER}
141145
S3_STYLE=${S3_STYLE}
142146
# Flag (true/false) enabling AWS signatures debug output (default: false)
143147
S3_DEBUG=${S3_DEBUG}
148+
# Proxy caching time for response code 200 and 302
149+
PROXY_CACHE_VALID_OK=${PROXY_CACHE_VALID_OK}
150+
# Proxy caching time for response code 404
151+
PROXY_CACHE_VALID_NOTFOUND=${PROXY_CACHE_VALID_NOTFOUND}
152+
# Proxy caching time for response code 403
153+
PROXY_CACHE_VALID_FORBIDDEN=${PROXY_CACHE_VALID_FORBIDDEN}
154+
# Enables or disables CORS for the S3 Gateway (true=enabled, false=disabled)
155+
CORS_ENABLED=${CORS_ENABLED}
144156
EOF
145157

158+
# By enabling CORS, we also need to enable the OPTIONS method which
159+
# is not normally used as part of the gateway. The following variable
160+
# defines the set of acceptable headers.
161+
if [ "${CORS_ENABLED}" == "1" ]; then
162+
cat >> "/etc/nginx/environment" << EOF
163+
LIMIT_METHODS_TO="GET HEAD OPTIONS"
164+
LIMIT_METHODS_TO_CSV="GET, HEAD, OPTIONS"
165+
EOF
166+
else
167+
cat >> "/etc/nginx/environment" << EOF
168+
LIMIT_METHODS_TO="GET HEAD"
169+
LIMIT_METHODS_TO_CSV="GET, HEAD"
170+
EOF
171+
fi
172+
173+
if [ -z "${CORS_ALLOWED_ORIGIN+x}" ]; then
174+
CORS_ALLOWED_ORIGIN="*"
175+
fi
176+
146177
# Only include these env vars if we are not using a instance profile credential
147178
# to obtain S3 permissions.
148179
if [ $uses_iam_creds -eq 0 ]; then
@@ -305,6 +336,11 @@ download "common/etc/nginx/templates/gateway/v2_headers.conf.template" "/etc/ngi
305336
download "common/etc/nginx/templates/gateway/v2_js_vars.conf.template" "/etc/nginx/templates/gateway/v2_js_vars.conf.template"
306337
download "common/etc/nginx/templates/gateway/v4_headers.conf.template" "/etc/nginx/templates/gateway/v4_headers.conf.template"
307338
download "common/etc/nginx/templates/gateway/v4_js_vars.conf.template" "/etc/nginx/templates/gateway/v4_js_vars.conf.template"
339+
download "common/etc/nginx/templates/gateway/cors.conf.template" "/etc/nginx/templates/gateway/cors.conf.template"
340+
download "common/etc/nginx/templates/gateway/js_fetch_trusted_certificate.conf.template" "/etc/nginx/templates/gateway/js_fetch_trusted_certificate.conf.template"
341+
download "common/etc/nginx/templates/gateway/s3listing_location.conf.template" "/etc/nginx/templates/gateway/s3listing_location.conf.template"
342+
download "common/etc/nginx/templates/gateway/s3_location.conf.template" "/etc/nginx/templates/gateway/s3_location.conf.template"
343+
download "common/etc/nginx/templates/gateway/s3_server.conf.template" "/etc/nginx/templates/gateway/s3_server.conf.template"
308344
download "oss/etc/nginx/templates/upstreams.conf.template" "/etc/nginx/templates/upstreams.conf.template"
309345
download "oss/etc/nginx/conf.d/gateway/server_variables.conf" "/etc/nginx/conf.d/gateway/server_variables.conf"
310346

0 commit comments

Comments
 (0)