Skip to content

Commit ec1e2c5

Browse files
committed
Add env var JS_TRUSTED_CERT_PATH
The JS_TRUSTED_CERT_PATH setting will now allow you to set the path for the js_fetch_trusted_certificate directive as used when retrieving AWS credentials. Signed-off-by: Elijah Zupancic <[email protected]>
1 parent 17d5ec4 commit ec1e2c5

File tree

8 files changed

+34
-8
lines changed

8 files changed

+34
-8
lines changed

Dockerfile.buildkit.plus

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ COPY plus/usr /usr
1111
# startup is the same.
1212
# Source: https://github.com/nginxinc/docker-nginx/tree/1.19.2/stable/buster
1313
COPY common/docker-entrypoint.sh /docker-entrypoint.sh
14-
COPY plus/docker-entrypoint.d /docker-entrypoint.d
14+
COPY common/docker-entrypoint.d /docker-entrypoint.d/
15+
COPY plus/docker-entrypoint.d /docker-entrypoint.d/
1516
# Add NGINX Plus package repository keyring
1617
COPY plus/usr/share/keyrings/nginx-archive-keyring.gpg /usr/share/keyrings/nginx-archive-keyring.gpg
1718

Dockerfile.oss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ENV PROXY_CACHE_VALID_FORBIDDEN "30s"
1717

1818
COPY common/etc /etc
1919
COPY common/docker-entrypoint.sh /docker-entrypoint.sh
20-
COPY common/docker-entrypoint.d/00-check-for-required-env.sh /docker-entrypoint.d/00-check-for-required-env.sh
20+
COPY common/docker-entrypoint.d /docker-entrypoint.d/
2121
COPY oss/etc /etc
2222

2323
RUN set -eux \

Dockerfile.plus

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ COPY plus/usr /usr
1414

1515
# Copy files from the OSS NGINX Docker container such that the container
1616
# startup is the same.
17-
# Source: https://github.com/nginxinc/docker-nginx/tree/1.19.2/stable/buster
1817
COPY common/docker-entrypoint.sh /docker-entrypoint.sh
19-
COPY plus/docker-entrypoint.d /docker-entrypoint.d
18+
COPY common/docker-entrypoint.d /docker-entrypoint.d/
19+
COPY plus/docker-entrypoint.d /docker-entrypoint.d/
2020
# Add NGINX Plus package repository keyring
2121
COPY plus/usr/share/keyrings/nginx-archive-keyring.gpg /usr/share/keyrings/nginx-archive-keyring.gpg
2222

common/docker-entrypoint.d/00-check-for-required-env.sh

100644100755
File mode changed.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
# Copyright 2022 F5 Networks
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
set -e
18+
19+
if [ -f /etc/nginx/conf.d/gateway/js_fetch_trusted_certificate.conf ] && [ -n "${JS_TRUSTED_CERT_PATH+x}" ]; then
20+
echo "js_fetch_trusted_certificate ${JS_TRUSTED_CERT_PATH};" >> /etc/nginx/conf.d/gateway/js_fetch_trusted_certificate.conf
21+
echo "Enabling js_fetch_trusted_certificate ${JS_TRUSTED_CERT_PATH}"
22+
fi

common/etc/nginx/templates/default.conf.template

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,8 @@ server {
7777
location /aws/credentials/retrieve {
7878
internal;
7979
js_content s3gateway.fetchCredentials;
80-
81-
# Enable the below line if you are seeing SSL Handshake error while connecing to s3 bucket
82-
# js_fetch_trusted_certificate /etc/ssl/certs/Amazon_Root_CA_1.pem;
80+
81+
include /etc/nginx/conf.d/gateway/js_fetch_trusted_certificate.conf;
8382
}
8483

8584
location @s3 {
@@ -172,7 +171,7 @@ server {
172171
}
173172

174173
location @trailslashControl {
175-
# Checks if requesting a folder without trailing slash, and return 302
174+
# Checks if requesting a folder without trailing slash, and return 302
176175
# appending a slash to it when using for static site hosting.
177176
js_content s3gateway.trailslashControl;
178177
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Enable js_fetch_trusted_certificate if you are seeing SSL Handshake error when connecing to S3
2+
# The following often works for connecting to AWS services:
3+
# js_fetch_trusted_certificate /etc/ssl/certs/Amazon_Root_CA_1.pem;

docs/getting_started.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ running as a Container or as a Systemd service.
3636
* `PROXY_CACHE_VALID_OK` - Sets caching time for response code 200 and 302
3737
* `PROXY_CACHE_VALID_NOTFOUND` - Sets caching time for response code 404
3838
* `PROXY_CACHE_VALID_FORBIDDEN` - Sets caching time for response code 403
39+
* `JS_TRUSTED_CERT_PATH` - (optional) Enables the `js_fetch_trusted_certificate` directive when retrieving AWS credentials and sets the path (on the container) to the specified path
3940

4041
If you are using [AWS instance profile credentials](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2.html),
4142
you will need to omit the `S3_ACCESS_KEY_ID` and `S3_SECRET_KEY` variables from

0 commit comments

Comments
 (0)