add REDIRECT_SCHEME to support running this image behind a SSL-termination proxy

This commit is contained in:
Michael Contento 2017-03-28 20:13:15 +02:00
parent 190712ffc1
commit 48724219b3
4 changed files with 7 additions and 2 deletions

View File

@ -33,6 +33,10 @@ ENV REDIRECT_MODE="none"
# Which HTTP code should we use for the above redirect
ENV REDIRECT_CODE=302
# And the protocol we should redirect to. Change this to "https" if you
# serve via https (e.g. with a SSL-termination proxy infront of this)
ENV REDIRECT_SCHEME="http"
ADD etc/ /etc/
ADD usr/ /usr/

View File

@ -1,5 +1,5 @@
server {
listen 80;
server_name ~^(?!www.)(?<domain>.+)$;
return {{REDIRECT_CODE}} https://www.$domain$request_uri;
return {{REDIRECT_CODE}} {{REDIRECT_SCHEME}}://www.$domain$request_uri;
}

View File

@ -1,5 +1,5 @@
server {
listen 80;
server_name ~^www.(?<domain>.+)$;
return {{REDIRECT_CODE}} https://$domain$request_uri;
return {{REDIRECT_CODE}} {{REDIRECT_SCHEME}}://$domain$request_uri;
}

View File

@ -7,6 +7,7 @@ for file in /etc/nginx/*/*.conf; do
sed -i \
-e "s#{{REDIRECT_CODE}}#${REDIRECT_CODE}#g" \
-e "s#{{DOCUMENT_ROOT}}#${DOCUMENT_ROOT}#g" \
-e "s#{{REDIRECT_SCHEME}}#${REDIRECT_SCHEME}#g" \
"${file}"
done