Skip to content

Commit 08228b3

Browse files
authored
v4.0.0 (#93)
## Major updates * **Breaking Change** configuration is now handled using a JSON file instead of `conf.sh` * Using `jq` to query JSON configuration file * Adding `ssl-conf-schema.json` ## Minor updates * Removing bash config sample file ## Documentation updates * Updating README with details of conf.json ## Build updates * Removing latest tag from publish
1 parent 95ea90b commit 08228b3

File tree

19 files changed

+120
-106
lines changed

19 files changed

+120
-106
lines changed

.github/workflows/publish.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,9 @@ jobs:
6464
push: true
6565
platforms: linux/amd64,linux/arm/v7,linux/arm64
6666
tags: |
67-
bfren/nginx-proxy:latest
6867
bfren/nginx-proxy:${{ steps.version_major.outputs.contents }}
6968
bfren/nginx-proxy:${{ steps.version_minor.outputs.contents }}
7069
bfren/nginx-proxy:${{ steps.version.outputs.contents }}
71-
ghcr.io/bfren/nginx-proxy:latest
7270
ghcr.io/bfren/nginx-proxy:${{ steps.version_major.outputs.contents }}
7371
ghcr.io/bfren/nginx-proxy:${{ steps.version_minor.outputs.contents }}
7472
ghcr.io/bfren/nginx-proxy:${{ steps.version.outputs.contents }}

README.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
Nginx Proxy which uses [getssl](https://github.com/srvrco/getssl) to automate requesting and renewing SSL certificates via Let's Encrypt. Certificates are checked for renewal every day - the last check can be viewed in the `/ssl` volume.
99

10+
As of v4, configuration is handled via a JSON file - see ssl-conf-sample.json for an example and ssl-conf-schema.json for the full file definition.
11+
1012
## Contents
1113

1214
* [Ports](#ports)
@@ -25,11 +27,11 @@ For SSL certificate requests to work correctly, ports 80 and 443 need mapping fr
2527

2628
## Volumes
2729

28-
| Volume | Purpose |
29-
| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
30-
| `/www` | *From base image.* |
31-
| `/sites` | Nginx site configuration, auto-generated on first run based on `conf.sh`. After they are generated, you can alter them to suit their needs. Running `nginx-regenerate` will wipe them all and start again. |
32-
| `/ssl` | Contains auto-generated SSL configuration and certificates (for backup purposes). Your `conf.sh` file should be stored in here for auto-configuration (see `ssl-conf-sample.sh`). Certificate update log (`update.log`) will be created here weekly. |
30+
| Volume | Purpose |
31+
| -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
32+
| `/www` | *From base image.* |
33+
| `/sites` | Nginx site configuration, auto-generated on first run based on `conf.json`. After they are generated, you can alter them to suit their needs. Running `nginx-regenerate` will wipe them all and start again. |
34+
| `/ssl` | Contains auto-generated SSL configuration and certificates (for backup purposes). Your `conf.json` file should be stored in here for auto-configuration (see `ssl-conf-sample.json`). Certificate update log (`update.log`) will be created here daily. |
3335

3436
## Environment Variables
3537

@@ -40,20 +42,20 @@ For SSL certificate requests to work correctly, ports 80 and 443 need mapping fr
4042
| `PROXY_LETS_ENCRYPT_EMAIL` | A valid email address | Used by Lets Encrypt for notification emails. | *None* - **required** |
4143
| `PROXY_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 |
4244
| `PROXY_SSL_DHPARAM_BITS` | A valid integer | The size of your DHPARAM variables - adjust down only if you have limited processing resources. | 4096 |
43-
| `PROXY_SSL_REDIRECT_TO_CANONICAL` | 0 or 1 | If 1, all requests will be redirected to the primary domain (defined in `conf.sh`). | 0 |
45+
| `PROXY_SSL_REDIRECT_TO_CANONICAL` | 0 or 1 | If 1, all requests will be redirected to the primary domain (defined in `conf.json`). | 0 |
4446
| `PROXY_GETSSL_SKIP_HTTP_TOKEN_CHECK` | true or false | Set to true to enable `getssl`'s [skip HTTP token check](https://github.com/srvrco/getssl/wiki/Config-variables#skip_http_token_checkfalse). | false |
4547

4648
## Helper Functions
4749

48-
| Function | Arguments | Description |
49-
| --------------------- | --------- | ---------------------------------------------------------------------------------------------------------------- |
50-
| `nginx-regenerate` | *None* | Removes Nginx configuration files (in `/sites`) and regenerates based on `conf.sh`. |
51-
| `ssl-cleanup` | *None* | Removes SSL and Nginx configuration files and directories not defined in `conf.sh`. |
52-
| `ssl-init` | *None* | Initialises SSL configuration based on `conf.sh`. |
53-
| `ssl-regenerate` | *None* | Removes SSL configuration files (in `/ssl/certs`) and regenerates based on `conf.sh`. |
54-
| `ssl-regenerate-full` | *None* | Removes SSL configuration files (in `/ssl/certs`), as well as DH parameters, and regenerates based on `conf.sh`. |
55-
| `ssl-request` | *None* | Requests SSL certificates from Lets Encrypt. |
56-
| `ssl-update` | *None* | Attempts to update SSL certificates manually. |
50+
| Function | Arguments | Description |
51+
| --------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------- |
52+
| `nginx-regenerate` | -f: force | Removes non-custom Nginx configuration files (in `/sites`) and regenerates based on `conf.json` (with force, removes all). |
53+
| `ssl-cleanup` | -m: mode | Removes SSL and Nginx configuration files and directories not defined in `conf.json` (mode 0 = dry run, 1 = live). |
54+
| `ssl-init` | *None* | Initialises SSL configuration based on `conf.json`. |
55+
| `ssl-regenerate` | *None* | Removes SSL configuration files (in `/ssl/certs`) and regenerates based on `conf.json`. |
56+
| `ssl-regenerate-full` | *None* | Removes SSL configuration files (in `/ssl/certs`), as well as DH parameters, and regenerates based on `conf.json`. |
57+
| `ssl-request` | *None* | Requests SSL certificates from Lets Encrypt. |
58+
| `ssl-update` | *None* | Attempts to update SSL certificates manually. |
5759

5860
## Nginx Configuration Helpers
5961

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.3.13
1+
4.0.0

VERSION_MAJOR

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3
1+
4

VERSION_MINOR

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.3
1+
4.0

overlay/etc/bf/templates/nginx-proxy.conf.esh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Use environment variable PROXY_URI to change this file.
66
#
7-
# Copyright (c) 2021 bfren
7+
# Copyright (c) 2021-2022 bfren
88
#======================================================================================================================
99

1010
#======================================================================================================================

overlay/etc/bf/templates/nginx-site.conf.esh

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
1-
<% if [ -z "${DOMAIN_NGXCONF}" ] ; then -%>
2-
#======================================================================================================================
3-
# WARNING: This file is generated. Do not make changes to this file.
4-
# Changes will be overwritten the next time the container is started.
5-
#
6-
# To add server names or aliases please use /ssl/conf.sh (see ssl-conf-sample.sh).
7-
#
8-
# If you need a fully custom configuration then add the following to /ssl/conf.sh:
9-
# NGXCONF["<%= "${DOMAIN_NAME}" %>"]="custom"
10-
# This will stop this file being generated next time the container is started.
11-
#
12-
# Copyright (c) 2021 bfren
13-
#======================================================================================================================
14-
<% else -%>
1+
<% if [ "${DOMAIN_NGXCONF}" = "true" ] ; then -%>
152
#======================================================================================================================
163
# You can make changes to this file.
174
#
@@ -23,11 +10,26 @@
2310
# d) custom configuration can be added to the /sites/<%= "${DOMAIN_NAME}" %>.d directory -
2411
# these are loaded as part of the HTTPS server block below
2512
#
26-
# If you would like to return to using generated configuration then remove the following from /ssl/conf.sh:
27-
# NGXCONF["<%= "${DOMAIN_NAME}" %>"]=""
13+
# If you would like to return to using generated configuration then remove the following from /ssl/conf.json in the
14+
# object where the primary domain is "<%= "${DOMAIN_NAME}" %>":
15+
# "custom": true
2816
# This will cause this file to be regenerated next time the container is started.
2917
#
30-
# Copyright (c) 2021 bfren
18+
# Copyright (c) 2021-2022 bfren
19+
#======================================================================================================================
20+
<% else -%>
21+
#======================================================================================================================
22+
# WARNING: This file is generated. Do not make changes to this file.
23+
# Changes will be overwritten the next time the container is started.
24+
#
25+
# To add server names or aliases please use /ssl/conf.sh (see ssl-conf-sample.sh).
26+
#
27+
# If you need a fully custom configuration then add the following to /ssl/conf.json in the object where the primary
28+
# domain is "<%= "${DOMAIN_NAME}" %>":
29+
# "custom": true
30+
# This will stop this file being generated next time the container is started.
31+
#
32+
# Copyright (c) 2021-2022 bfren
3133
#======================================================================================================================
3234
<% fi %>
3335
#======================================================================================================================

overlay/tmp/install

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ bf-echo "Installing packages..."
1212
apk add --no-cache \
1313
bash \
1414
curl \
15+
jq \
1516
openssl
1617
bf-done
1718

overlay/usr/bin/bf/nginx-regenerate

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ done
3232

3333
bf-echo "Loading SSL configuration."
3434
source ${BF_INC}/proxy-load-conf.sh
35-
bf-debug "Loaded: ${!DOMAINS[*]}."
35+
bf-debug "Loaded: ${DOMAINS[*]}."
3636

3737

3838
#======================================================================================================================
@@ -54,7 +54,8 @@ for CFG in "${NGINX_CONFIGS[@]}" ; do
5454
bf-debug " .. ${STRIPPED}"
5555

5656
# the domain has standard config - delete conf file
57-
if [[ -z "${NGXCONF[${STRIPPED}]-}" ]] ; then
57+
CUSTOM_CONF=`get-custom "${STRIPPED}"`
58+
if [[ "${CUSTOM_CONF}" = "false" ]] ; then
5859

5960
bf-debug " .. standard config: remove configuration file"
6061
rm -f ${PROXY_SITES}/${STRIPPED}.conf

overlay/usr/bin/bf/ssl-cleanup

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ esac
4242
remove () {
4343

4444
if [ "${MODE}" = "0" ] ; then
45-
bf-echo " .. will remove ${1}/*"
45+
bf-echo " .. will remove ${1}*"
4646
elif [ "${MODE}" = "1" ] ; then
47-
bf-echo " .. removing ${1}/*"
47+
bf-echo " .. removing ${1}*"
4848
bf-rmrf ${1}* > /dev/null 2>&1
4949
fi
5050

@@ -57,7 +57,7 @@ remove () {
5757

5858
bf-echo "Loading SSL configuration."
5959
source ${BF_INC}/proxy-load-conf.sh
60-
bf-debug "Loaded: ${!DOMAINS[*]}."
60+
bf-debug "Loaded: ${DOMAINS[*]}."
6161

6262

6363
#======================================================================================================================
@@ -79,7 +79,7 @@ for CFG in "${SSL_CONFIGS[@]}" ; do
7979

8080
# if NAME is not the main PROXY_URI nor in the DOMAINS array, delete everything
8181
[[ "${PROXY_URI}" != "${NAME}" ]] \
82-
&& [[ ! " ${!DOMAINS[*]} " =~ " ${NAME} " ]] \
82+
&& [[ -z "`get-domain ${NAME}`" ]] \
8383
&& remove "${PROXY_SSL_CERTS}/${NAME}"
8484

8585
done
@@ -105,7 +105,7 @@ for CFG in "${NGINX_CONFIGS[@]}" ; do
105105

106106
# if STRIPPED is not the main PROXY_URI nor in the DOMAINS array, delete everything
107107
[[ "${PROXY_URI}" != "${STRIPPED}" ]] \
108-
&& [[ ! " ${!DOMAINS[*]} " =~ " ${STRIPPED} " ]] \
108+
&& [[ -z "`get-domain ${STRIPPED}`" ]] \
109109
&& remove "${PROXY_SITES}/${STRIPPED}"
110110

111111
done

0 commit comments

Comments
 (0)