@@ -81,6 +81,10 @@ echo "Addressing Style: ${S3_STYLE}"
81
81
echo " AWS Signatures Version: v${AWS_SIGS_VERSION} "
82
82
echo " DNS Resolvers: ${DNS_RESOLVERS} "
83
83
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} "
84
88
85
89
set -o nounset # abort on unbound variable
86
90
123
127
124
128
echo " ▶ Adding environment variables to NGINX configuration file: /etc/nginx/environment"
125
129
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)
127
131
ALLOW_DIRECTORY_LIST=${ALLOW_DIRECTORY_LIST}
128
132
# AWS Authentication signature version (2=v2 authentication, 4=v4 authentication)
129
133
AWS_SIGS_VERSION=${AWS_SIGS_VERSION}
@@ -141,8 +145,35 @@ S3_SERVER=${S3_SERVER}
141
145
S3_STYLE=${S3_STYLE}
142
146
# Flag (true/false) enabling AWS signatures debug output (default: false)
143
147
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}
144
156
EOF
145
157
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
+
146
177
# Only include these env vars if we are not using a instance profile credential
147
178
# to obtain S3 permissions.
148
179
if [ $uses_iam_creds -eq 0 ]; then
@@ -305,6 +336,11 @@ download "common/etc/nginx/templates/gateway/v2_headers.conf.template" "/etc/ngi
305
336
download " common/etc/nginx/templates/gateway/v2_js_vars.conf.template" " /etc/nginx/templates/gateway/v2_js_vars.conf.template"
306
337
download " common/etc/nginx/templates/gateway/v4_headers.conf.template" " /etc/nginx/templates/gateway/v4_headers.conf.template"
307
338
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"
308
344
download " oss/etc/nginx/templates/upstreams.conf.template" " /etc/nginx/templates/upstreams.conf.template"
309
345
download " oss/etc/nginx/conf.d/gateway/server_variables.conf" " /etc/nginx/conf.d/gateway/server_variables.conf"
310
346
0 commit comments