Skip to content

Commit e0a4be3

Browse files
committed
Move header detection into nginx conf.
This should make it easier to read later Signed-off-by: Brian Warner <brian@bdwarner.com>
1 parent 0e2b38c commit e0a4be3

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ COPY cfg/purge.php /usr/share/nginx/html/
2525
# access environment variables without significant workarounds. Furthermore, the variables are
2626
# required because nginx does not currently support nested if statements.
2727
RUN if [ -n "$CDN_ACCESS_KEY" ]; then \
28-
sed -i s/##PLACEHOLDER-cdn_header_detection-DO_NOT_CHANGE##/"map \$http_x_cdn_access \$reroute_to_cdn { default '1'; $CDN_ACCESS_KEY '0'; }"/g /etc/nginx/conf.d/default.conf && \
29-
sed -i s/##PLACEHOLDER-cdn_reroute-DO_NOT_CHANGE##/"if (\$reroute_to_cdn) { return 301 \$scheme:\/\/code.jquery.com\$uri; }"/g /etc/nginx/conf.d/default.conf; \
28+
sed -i s/CDN_ACCESS_KEY_PLACEHOLDER/$CDN_ACCESS_KEY/g /etc/nginx/conf.d/default.conf && \
29+
sed -i s/##ACTIVATE-XCDNACCESS##//g /etc/nginx/conf.d/default.conf; \
3030
fi
3131

3232
# Load the releases into the container

cfg/default.conf

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
# Increase map_hash_bucket_size to accommodate longer CDN tokens
1616
map_hash_bucket_size 128;
1717

18-
# Do not change the following line. The Dockerfile will add CDN header detection at build time if
19-
# the correct environment variable is set.
20-
21-
##PLACEHOLDER-cdn_header_detection-DO_NOT_CHANGE##
18+
# Do not change the following lines. The Dockerfile will set the access key and remove the comment
19+
# at build time if the correct environment variable is set.
20+
##ACTIVATE-XCDNACCESS##map $http_x_cdn_access $reroute_to_cdn { default '1'; CDN_ACCESS_KEY_PLACEHOLDER '0'; }
2221

2322
server {
2423
listen 80;
@@ -31,9 +30,9 @@ server {
3130
root /usr/share/nginx/html;
3231
index index.html index.htm;
3332

34-
# Do not change the following line. The Dockerfile will add the reroute logic at build time if
35-
# the correct environment variable is set.
36-
##PLACEHOLDER-cdn_reroute-DO_NOT_CHANGE##
33+
# Do not change the following line. The Dockerfile will set the access key and remove the
34+
# comment at build time if the correct environment variable is set.
35+
##ACTIVATE-XCDNACCESS##if ($reroute_to_cdn) { return 301 \$scheme:\/\/code.jquery.com\$uri; }
3736

3837
}
3938

0 commit comments

Comments
 (0)