Skip to content

Commit f38688d

Browse files
authored
v1.3.1 (#17)
Major updates * Using latest Nginx base image * Adding required PROXY_URI environment variable * Add default server configuration * Namespacing helper configuration files * Adding maintenance page for HTTP 502/503/504 errors
1 parent 4efac5c commit f38688d

File tree

13 files changed

+119
-27
lines changed

13 files changed

+119
-27
lines changed

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#FROM bcgdesign/nginx:alpine-3.13-1.3.0
2-
FROM bcgdesign/nginx:dev
1+
FROM bcgdesign/nginx:alpine-3.13-1.3.2
32

43
LABEL maintainer="Ben Green <[email protected]>" \
54
org.label-schema.name="Nginx Proxy" \
@@ -13,6 +12,8 @@ EXPOSE 443
1312
ENV \
1413
# used for renewal notification emails
1514
LETS_ENCRYPT_EMAIL= \
15+
# the base URI of the proxy server (will be used when SSL bindings fail)
16+
PROXY_URI= \
1617
# clean all config and certificates before doing anything else
1718
CLEAN_INSTALL=0 \
1819
# set to 1 to use live instead of staging server
@@ -33,7 +34,6 @@ RUN apk -U upgrade \
3334
curl \
3435
gomplate=${GOMPLATE_VERSION} \
3536
openssl \
36-
&& mv /etc/nginx/sites/localhost.conf /etc/nginx/http.d/default.conf \
3737
&& rm -rf /var/cache/apk/* /etc/nginx/sites /tmp/*
3838

3939
COPY ./overlay /

Dockerfile-automated

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ EXPOSE 443
1212
ENV \
1313
# used for renewal notification emails
1414
LETS_ENCRYPT_EMAIL= \
15+
# the base URI of the proxy server (will be used when SSL bindings fail)
16+
PROXY_URI= \
1517
# clean all config and certificates before doing anything else
1618
CLEAN_INSTALL=0 \
1719
# set to 1 to use live instead of staging server
@@ -32,7 +34,6 @@ RUN apk -U upgrade \
3234
curl \
3335
gomplate=${GOMPLATE_VERSION} \
3436
openssl \
35-
&& mv /etc/nginx/sites/localhost.conf /etc/nginx/http.d/default.conf \
3637
&& rm -rf /var/cache/apk/* /etc/nginx/sites /tmp/*
3738

3839
COPY ./overlay /

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ For SSL certificate requests to work correctly, ports 80 and 443 need mapping fr
3535
| Variable | Values | Description | Default |
3636
| ------------------------------ | --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- |
3737
| `LETS_ENCRYPT_EMAIL` | A valid email address | Used by Lets Encrypt for notification emails. | *None* - **required** |
38+
| `PROXY_URI` | URI | The base URI of the proxy server - will be used to handle unbound requests. | *None* - **required** |
3839
| `CLEAN_INSTALL` | 0 or 1 | If 1, all Nginx and SSL configuration and certificates will be deleted and regenerated. | 0 |
3940
| `LETS_ENCRYPT_LIVE` | 0 or 1 | Only set to 1 (to request live certificates) when your config is correct - Lets Encrypt rate limit certificate requests. | 0 |
4041
| `SSL_DHPARAM_BITS` | A valid integer | The size of your DHPARAM variables - adjust down only if you have limited processing resources. | 4096 |
@@ -54,14 +55,14 @@ For SSL certificate requests to work correctly, ports 80 and 443 need mapping fr
5455

5556
## Nginx Configuration Helpers
5657

57-
The image contains a handful of useful Nginx configuration 'helper' files, which you can find in `/overlay/etc/nginx/helpers`.
58+
The image contains a handful of useful Nginx configuration 'helper' files, which you can find in `/overlay/etc/nginx/helpers`. They all begin with the prefix 'proxy':
5859

59-
| Helper | Description |
60-
| --------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
61-
| `proxy-params.conf` | Headers commonly required when proxying a site. |
62-
| `proxy-params-websockets.conf` | Headers required to use websockets. |
63-
| `secure-headers.conf` | Standard secure headers - see [Mozilla SSL Configuration Generator](https://ssl-config.mozilla.org/). |
64-
| `tls1_3-only.conf` | If you want to be ultra-secure (and not support older browsers), this will disable all TLS protocols except 1.3. |
60+
| Helper | Description |
61+
| ------------------------- | ---------------------------------------------------------------------------------------------------------------- |
62+
| `-params.conf` | Headers commonly required when proxying a site. |
63+
| `-params-websockets.conf` | Headers required to use websockets. |
64+
| `-secure-headers.conf` | Standard secure headers - see [Mozilla SSL Configuration Generator](https://ssl-config.mozilla.org/). |
65+
| `-tls1_3-only.conf` | If you want to be ultra-secure (and not support older browsers), this will disable all TLS protocols except 1.3. |
6566

6667
## Authors
6768

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.3.0
1+
1.3.1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
location = /maintenance.html {
2+
root /www;
3+
}

overlay/etc/ssl/inc/setup-nginx.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
setup_nginx () {
1212

1313
# give arguments friendly names
14-
export DOMAIN_NAME=${1}
15-
export UPSTREAM=${2}
16-
local -n DOMAIN_ALIASES=${3}
17-
export DOMAIN_NGXCONF=${4}
14+
export IS_DEFAULT=${1}
15+
export DOMAIN_NAME=${2}
16+
export UPSTREAM=${3}
17+
local -n DOMAIN_ALIASES=${4}
18+
export DOMAIN_NGXCONF=${5}
1819

1920
# paths to site configuration and custom config directory
2021
local SITE="${SITES}/${DOMAIN_NAME}"
@@ -50,8 +51,14 @@ setup_nginx () {
5051
export SERVER_NAMES=$(echo "${TMP}" | xargs)
5152

5253
# generate site configuration
54+
if [ "${IS_DEFAULT}" = "1" ] ; then
55+
NGINX_CONF="default"
56+
else
57+
NGINX_CONF="site"
58+
fi
59+
5360
gomplate \
5461
-o ${CONF} \
55-
-f ${TEMPLATES}/nginx-site.conf.tmpl
62+
-f ${TEMPLATES}/nginx-${NGINX_CONF}.conf.tmpl
5663

5764
}

overlay/etc/ssl/init

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,24 @@ setup_global
2626
_done
2727

2828

29+
#======================================================================================================================
30+
# Check for PROXY_URI
31+
#======================================================================================================================
32+
33+
[[ -z "${PROXY_URI-}" ]] && _error "PROXY_URI must be set."
34+
35+
_echo "Setting up default server ${PROXY_URI}..."
36+
declare -a BLANK_ALIAS=()
37+
38+
_echo " . Nginx..."
39+
setup_nginx 1 ${PROXY_URI} "http://localhost" BLANK_ALIAS ""
40+
41+
_echo " . SSL..."
42+
setup_ssl ${PROXY_URI} BLANK_ALIAS
43+
44+
_ok " . done."
45+
46+
2947
#======================================================================================================================
3048
# Set up Nginx and SSL for each primary domain
3149
#======================================================================================================================
@@ -40,7 +58,7 @@ for DN in "${!DOMAINS[@]}" ; do
4058
_echo " .. ${DN}"
4159

4260
_echo " . Nginx..."
43-
setup_nginx ${DN} ${UP} AL ${CF}
61+
setup_nginx 0 ${DN} ${UP} AL ${CF}
4462

4563
_echo " . SSL..."
4664
setup_ssl ${DN} AL

overlay/etc/ssl/request

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ source ${INC}/check.sh
1313
# -w set working directory
1414
#======================================================================================================================
1515

16+
request() { /etc/ssl/getssl -U -w ${SSL_CERTS} ${1} ; }
17+
1618
_echo "Requesting SSL certificates..."
17-
for D in "${!DOMAINS[@]}" ; do
18-
_echo " .. ${D}"
19-
/etc/ssl/getssl -U -w ${SSL_CERTS} ${D}
19+
request "${PROXY_URI}"
20+
for DN in "${!DOMAINS[@]}" ; do
21+
_echo " .. ${DN}"
22+
request ${DN}
2023
done
2124
_done

0 commit comments

Comments
 (0)