Skip to content

Commit d376c95

Browse files
authored
Merge pull request #526 from linuxserver/3.21
2 parents 9a63c22 + 29bd5fe commit d376c95

File tree

15 files changed

+83
-67
lines changed

15 files changed

+83
-67
lines changed

Dockerfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# syntax=docker/dockerfile:1
22

3-
FROM ghcr.io/linuxserver/baseimage-alpine-nginx:3.20
3+
FROM ghcr.io/linuxserver/baseimage-alpine-nginx:3.21
44

55
# set version label
66
ARG BUILD_DATE
@@ -88,7 +88,7 @@ RUN \
8888
pip install -U --no-cache-dir \
8989
pip \
9090
wheel && \
91-
pip install -U --no-cache-dir --find-links https://wheel-index.linuxserver.io/alpine-3.20/ \
91+
pip install -U --no-cache-dir --find-links https://wheel-index.linuxserver.io/alpine-3.21/ \
9292
certbot==${CERTBOT_VERSION} \
9393
certbot-dns-acmedns \
9494
certbot-dns-aliyun \
@@ -150,9 +150,9 @@ RUN \
150150
rm -f /etc/nginx/conf.d/stream.conf && \
151151
echo "**** correct ip6tables legacy issue ****" && \
152152
rm \
153-
/sbin/ip6tables && \
153+
/usr/sbin/ip6tables && \
154154
ln -s \
155-
/sbin/ip6tables-nft /sbin/ip6tables && \
155+
/usr/sbin/ip6tables-nft /usr/sbin/ip6tables && \
156156
echo "**** remove unnecessary fail2ban filters ****" && \
157157
rm \
158158
/etc/fail2ban/jail.d/alpine-ssh.conf && \

Dockerfile.aarch64

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# syntax=docker/dockerfile:1
22

3-
FROM ghcr.io/linuxserver/baseimage-alpine-nginx:arm64v8-3.20
3+
FROM ghcr.io/linuxserver/baseimage-alpine-nginx:arm64v8-3.21
44

55
# set version label
66
ARG BUILD_DATE
@@ -88,7 +88,7 @@ RUN \
8888
pip install -U --no-cache-dir \
8989
pip \
9090
wheel && \
91-
pip install -U --no-cache-dir --find-links https://wheel-index.linuxserver.io/alpine-3.20/ \
91+
pip install -U --no-cache-dir --find-links https://wheel-index.linuxserver.io/alpine-3.21/ \
9292
certbot==${CERTBOT_VERSION} \
9393
certbot-dns-acmedns \
9494
certbot-dns-aliyun \
@@ -150,9 +150,9 @@ RUN \
150150
rm -f /etc/nginx/conf.d/stream.conf && \
151151
echo "**** correct ip6tables legacy issue ****" && \
152152
rm \
153-
/sbin/ip6tables && \
153+
/usr/sbin/ip6tables && \
154154
ln -s \
155-
/sbin/ip6tables-nft /sbin/ip6tables && \
155+
/usr/sbin/ip6tables-nft /usr/sbin/ip6tables && \
156156
echo "**** remove unnecessary fail2ban filters ****" && \
157157
rm \
158158
/etc/fail2ban/jail.d/alpine-ssh.conf && \

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,15 @@ This will *ask* Google et al not to index and list your site. Be careful with th
149149

150150
Please follow the instructions [on this blog post](https://www.linuxserver.io/blog/2020-08-21-introducing-swag#migrate).
151151

152+
## Read-Only Operation
153+
154+
This image can be run with a read-only container filesystem. For details please [read the docs](https://docs.linuxserver.io/misc/read-only/).
155+
156+
### Caveats
157+
158+
* `/tmp` must be mounted to tmpfs
159+
* fail2ban will not be available
160+
152161
## Usage
153162

154163
To help you get started creating a container from this image you can either use docker-compose or the docker cli.
@@ -180,6 +189,7 @@ services:
180189
- ONLY_SUBDOMAINS=false #optional
181190
- EXTRA_DOMAINS= #optional
182191
- STAGING=false #optional
192+
- DISABLE_F2B= #optional
183193
volumes:
184194
- /path/to/swag/config:/config
185195
ports:
@@ -207,6 +217,7 @@ docker run -d \
207217
-e ONLY_SUBDOMAINS=false `#optional` \
208218
-e EXTRA_DOMAINS= `#optional` \
209219
-e STAGING=false `#optional` \
220+
-e DISABLE_F2B= `#optional` \
210221
-p 443:443 \
211222
-p 80:80 `#optional` \
212223
-v /path/to/swag/config:/config \
@@ -235,7 +246,9 @@ Containers are configured using parameters passed at runtime (such as those abov
235246
| `-e ONLY_SUBDOMAINS=false` | If you wish to get certs only for certain subdomains, but not the main domain (main domain may be hosted on another machine and cannot be validated), set this to `true` |
236247
| `-e EXTRA_DOMAINS=` | Additional fully qualified domain names (comma separated, no spaces) ie. `example.net,subdomain.example.net,*.example.org` |
237248
| `-e STAGING=false` | Set to `true` to retrieve certs in staging mode. Rate limits will be much higher, but the resulting cert will not pass the browser's security test. Only to be used for testing purposes. |
249+
| `-e DISABLE_F2B=` | Set to `true` to disable the Fail2ban service in the container, if you're already running it elsewhere or using a different IPS. |
238250
| `-v /config` | Persistent config files |
251+
| `--read-only=true` | Run container with a read-only filesystem. Please [read the docs](https://docs.linuxserver.io/misc/read-only/). |
239252
| `--cap-add=NET_ADMIN` | Required for fail2Ban to be able to modify iptables rules. |
240253

241254
### Portainer notice
@@ -404,6 +417,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
404417

405418
## Versions
406419

420+
* **17.12.24:** - Rebase to Alpine 3.21.
407421
* **21.10.24:** - Fix naming issue with Dynu plugin. If you are using Dynu, please make sure your credentials are set in /config/dns-conf/dynu.ini and your DNSPLUGIN variable is set to dynu (not dynudns).
408422
* **30.08.24:** - Fix zerossl cert revocation.
409423
* **24.07.14:** - Rebase to Alpine 3.20. Remove deprecated Google Domains certbot plugin. Existing users should update their nginx confs to avoid http2 deprecation warnings.

readme-vars.yml

+6
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,14 @@ opt_param_env_vars:
3737
- {env_var: "ONLY_SUBDOMAINS", env_value: "false", desc: "If you wish to get certs only for certain subdomains, but not the main domain (main domain may be hosted on another machine and cannot be validated), set this to `true`"}
3838
- {env_var: "EXTRA_DOMAINS", env_value: "", desc: "Additional fully qualified domain names (comma separated, no spaces) ie. `example.net,subdomain.example.net,*.example.org`"}
3939
- {env_var: "STAGING", env_value: "false", desc: "Set to `true` to retrieve certs in staging mode. Rate limits will be much higher, but the resulting cert will not pass the browser's security test. Only to be used for testing purposes."}
40+
- {env_var: "DISABLE_F2B", env_value: "", desc: "Set to `true` to disable the Fail2ban service in the container, if you're already running it elsewhere or using a different IPS."}
4041
opt_param_usage_include_ports: true
4142
opt_param_ports:
4243
- {external_port: "80", internal_port: "80", port_desc: "HTTP port (required for HTTP validation and HTTP -> HTTPS redirect)"}
44+
readonly_supported: true
45+
readonly_message: |
46+
* `/tmp` must be mounted to tmpfs
47+
* fail2ban will not be available
4348
# application setup block
4449
app_setup_block_enabled: true
4550
app_setup_block: |
@@ -200,6 +205,7 @@ init_diagram: |
200205
"swag:latest" <- Base Images
201206
# changelog
202207
changelogs:
208+
- {date: "17.12.24:", desc: "Rebase to Alpine 3.21."}
203209
- {date: "21.10.24:", desc: "Fix naming issue with Dynu plugin. If you are using Dynu, please make sure your credentials are set in /config/dns-conf/dynu.ini and your DNSPLUGIN variable is set to dynu (not dynudns)."}
204210
- {date: "30.08.24:", desc: "Fix zerossl cert revocation."}
205211
- {date: "24.07.14:", desc: "Rebase to Alpine 3.20. Remove deprecated Google Domains certbot plugin. Existing users should update their nginx confs to avoid http2 deprecation warnings."}

root/app/le-renew.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ echo
66
echo "<------------------------------------------------->"
77
echo "cronjob running on $(date)"
88
echo "Running certbot renew"
9-
certbot renew --non-interactive
9+
certbot renew --non-interactive --config-dir /config/etc/letsencrypt --logs-dir /config/log/letsencrypt --work-dir /tmp/letsencrypt --config /config/etc/letsencrypt/cli.ini

root/defaults/etc/letsencrypt/renewal-hooks/deploy/10-default

100644100755
File mode changed.

root/defaults/etc/letsencrypt/renewal-hooks/post/10-nginx

100644100755
File mode changed.

root/defaults/etc/letsencrypt/renewal-hooks/pre/10-nginx

100644100755
File mode changed.

root/defaults/nginx/site-confs/default.conf.sample

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Version 2024/07/16 - Changelog: https://github.com/linuxserver/docker-swag/commits/master/root/defaults/nginx/site-confs/default.conf.sample
1+
## Version 2024/12/17 - Changelog: https://github.com/linuxserver/docker-swag/commits/master/root/defaults/nginx/site-confs/default.conf.sample
22

33
# redirect all traffic to https
44
server {
@@ -80,5 +80,3 @@ server {
8080

8181
# enable subdomain method reverse proxy confs
8282
include /config/nginx/proxy-confs/*.subdomain.conf;
83-
# enable proxy cache for auth
84-
proxy_cache_path cache/ keys_zone=auth_cache:10m;

root/etc/crontabs/root

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
0 3 * * 6 run-parts /etc/periodic/weekly
66
0 5 1 * * run-parts /etc/periodic/monthly
77

8-
8 2 * * * /app/le-renew.sh >> /config/log/letsencrypt/letsencrypt.log 2>&1
8+
8 2 * * * /app/le-renew.sh >> /config/log/letsencrypt/renewal.log 2>&1

root/etc/s6-overlay/s6-rc.d/init-certbot-config/run

+9-16
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ if [[ "${VALIDATION}" = "dns" ]] && ! echo "${CERTBOT_DNS_AUTHENTICATORS}" | gre
3838
sleep infinity
3939
fi
4040

41-
# set owner of certbot's CONFIG_DIR, WORK_DIR, and LOGS_DIR to abc
42-
lsiown -R abc:abc \
43-
/etc/letsencrypt \
44-
/var/lib/letsencrypt \
45-
/var/log/letsencrypt
46-
4741
# set_ini_value logic:
4842
# - if the name is not found in the file, append the name=value to the end of the file
4943
# - if the name is found in the file, replace the value
@@ -67,7 +61,6 @@ cp -n /defaults/dns-conf/* /config/dns-conf/ 2> >(grep -v 'cp: not replacing')
6761
lsiown -R abc:abc /config/dns-conf
6862

6963
# copy default renewal hooks
70-
chmod -R +x /defaults/etc/letsencrypt/renewal-hooks
7164
cp -nR /defaults/etc/letsencrypt/renewal-hooks/* /config/etc/letsencrypt/renewal-hooks/ 2> >(grep -v 'cp: not replacing')
7265
lsiown -R abc:abc /config/etc/letsencrypt/renewal-hooks
7366

@@ -169,14 +162,14 @@ fi
169162
rm -rf /config/keys/letsencrypt
170163
if [[ "${ONLY_SUBDOMAINS}" = "true" ]] && [[ ! "${SUBDOMAINS}" = "wildcard" ]]; then
171164
DOMAIN="$(echo "${SUBDOMAINS}" | tr ',' ' ' | awk '{print $1}').${URL}"
172-
ln -s ../etc/letsencrypt/live/"${DOMAIN}" /config/keys/letsencrypt
165+
ln -s /config/etc/letsencrypt/live/"${DOMAIN}" /config/keys/letsencrypt
173166
else
174-
ln -s ../etc/letsencrypt/live/"${URL}" /config/keys/letsencrypt
167+
ln -s /config/etc/letsencrypt/live/"${URL}" /config/keys/letsencrypt
175168
fi
176169

177170
# cleanup unused csr and keys folders
178-
rm -rf /etc/letsencrypt/csr
179-
rm -rf /etc/letsencrypt/keys
171+
rm -rf /config/etc/letsencrypt/csr
172+
rm -rf /config/etc/letsencrypt/keys
180173

181174
# checking for changes in cert variables, revoking certs if necessary
182175
if [[ ! "${URL}" = "${ORIGURL}" ]] ||
@@ -197,9 +190,9 @@ if [[ ! "${URL}" = "${ORIGURL}" ]] ||
197190
REV_ACMESERVER=("https://acme-v02.api.letsencrypt.org/directory")
198191
fi
199192
if [[ -f /config/etc/letsencrypt/live/"${ORIGDOMAIN}"/fullchain.pem ]]; then
200-
certbot revoke --non-interactive --cert-path /config/etc/letsencrypt/live/"${ORIGDOMAIN}"/fullchain.pem --key-path /config/etc/letsencrypt/live/"${ORIGDOMAIN}"/privkey.pem --server "${REV_ACMESERVER[@]}" || true
193+
certbot revoke --config-dir /config/etc/letsencrypt --logs-dir /config/log/letsencrypt --work-dir /tmp/letsencrypt --config /config/etc/letsencrypt/cli.ini --non-interactive --cert-path /config/etc/letsencrypt/live/"${ORIGDOMAIN}"/fullchain.pem --key-path /config/etc/letsencrypt/live/"${ORIGDOMAIN}"/privkey.pem --server "${REV_ACMESERVER[@]}" || true
201194
else
202-
certbot revoke --non-interactive --cert-name "${ORIGDOMAIN}" --server "${REV_ACMESERVER[@]}" || true
195+
certbot revoke --config-dir /config/etc/letsencrypt --logs-dir /config/log/letsencrypt --work-dir /tmp/letsencrypt --config /config/etc/letsencrypt/cli.ini --non-interactive --cert-name "${ORIGDOMAIN}" --server "${REV_ACMESERVER[@]}" || true
203196
fi
204197
rm -rf /config/etc/letsencrypt/{accounts,archive,live,renewal}
205198
fi
@@ -212,9 +205,9 @@ if [[ -f "/config/keys/letsencrypt/chain.pem" ]] && { [[ "${CERTPROVIDER}" == "l
212205
echo "The cert seems to be using the old LE root cert, which is no longer valid. Deleting and revoking."
213206
REV_ACMESERVER=("https://acme-v02.api.letsencrypt.org/directory")
214207
if [[ -f /config/etc/letsencrypt/live/"${ORIGDOMAIN}"/fullchain.pem ]]; then
215-
certbot revoke --non-interactive --cert-path /config/etc/letsencrypt/live/"${ORIGDOMAIN}"/fullchain.pem --server "${REV_ACMESERVER[@]}" || true
208+
certbot revoke --config-dir /config/etc/letsencrypt --logs-dir /config/log/letsencrypt --work-dir /tmp/letsencrypt --config /config/etc/letsencrypt/cli.ini --non-interactive --cert-path /config/etc/letsencrypt/live/"${ORIGDOMAIN}"/fullchain.pem --server "${REV_ACMESERVER[@]}" || true
216209
else
217-
certbot revoke --non-interactive --cert-name "${ORIGDOMAIN}" --server "${REV_ACMESERVER[@]}" || true
210+
certbot revoke --config-dir /config/etc/letsencrypt --logs-dir /config/log/letsencrypt --work-dir /tmp/letsencrypt --config /config/etc/letsencrypt/cli.ini --non-interactive --cert-name "${ORIGDOMAIN}" --server "${REV_ACMESERVER[@]}" || true
218211
fi
219212
rm -rf /config/etc/letsencrypt/{accounts,archive,live,renewal}
220213
fi
@@ -347,7 +340,7 @@ if [[ ! -f "/config/keys/letsencrypt/fullchain.pem" ]]; then
347340
set_ini_value "eab-hmac-key" "${ZEROSSL_EAB_HMAC_KEY}" /config/etc/letsencrypt/cli.ini
348341
fi
349342
echo "Generating new certificate"
350-
certbot certonly --non-interactive --renew-by-default
343+
certbot certonly --config-dir /config/etc/letsencrypt --logs-dir /config/log/letsencrypt --work-dir /tmp/letsencrypt --config /config/etc/letsencrypt/cli.ini --non-interactive --renew-by-default
351344
if [[ ! -d /config/keys/letsencrypt ]]; then
352345
if [[ "${VALIDATION}" = "dns" ]]; then
353346
echo "ERROR: Cert does not exist! Please see the validation error above. Make sure you entered correct credentials into the ${DNSCREDENTIALFILE} file."
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,40 @@
11
#!/usr/bin/with-contenv bash
22
# shellcheck shell=bash
33

4-
if ! iptables -L &> /dev/null; then
5-
ln -sf /sbin/xtables-legacy-multi /sbin/iptables
6-
ln -sf /sbin/xtables-legacy-multi /sbin/iptables-save
7-
ln -sf /sbin/xtables-legacy-multi /sbin/iptables-restore
8-
ln -sf /sbin/xtables-legacy-multi /sbin/ip6tables
9-
ln -sf /sbin/xtables-legacy-multi /sbin/ip6tables-save
10-
ln -sf /sbin/xtables-legacy-multi /sbin/ip6tables-restore
11-
fi
4+
if [[ -z ${LSIO_READ_ONLY_FS} ]] && [[ -z ${LSIO_NON_ROOT_USER} ]] && [[ "${DISABLE_F2B,,}" != "true" ]]; then
5+
if ! iptables -L &> /dev/null; then
6+
ln -sf /usr/sbin/xtables-legacy-multi /usr/sbin/iptables
7+
ln -sf /usr/sbin/xtables-legacy-multi /usr/sbin/iptables-save
8+
ln -sf /usr/sbin/xtables-legacy-multi /usr/sbin/iptables-restore
9+
ln -sf /usr/sbin/xtables-legacy-multi /usr/sbin/ip6tables
10+
ln -sf /usr/sbin/xtables-legacy-multi /usr/sbin/ip6tables-save
11+
ln -sf /usr/sbin/xtables-legacy-multi /usr/sbin/ip6tables-restore
12+
fi
1213

13-
# copy/update the fail2ban config defaults to/in /config
14-
cp -R /defaults/fail2ban/filter.d /config/fail2ban/
15-
cp -R /defaults/fail2ban/action.d /config/fail2ban/
16-
# if jail.local is missing in /config, copy default
17-
if [[ ! -f /config/fail2ban/jail.local ]]; then
18-
cp /defaults/fail2ban/jail.local /config/fail2ban/jail.local
19-
fi
20-
# Replace fail2ban config with user config
21-
if [[ -d /etc/fail2ban/filter.d ]]; then
22-
rm -rf /etc/fail2ban/filter.d
23-
fi
24-
if [[ -d /etc/fail2ban/action.d ]]; then
25-
rm -rf /etc/fail2ban/action.d
26-
fi
27-
cp -R /config/fail2ban/filter.d /etc/fail2ban/
28-
cp -R /config/fail2ban/action.d /etc/fail2ban/
29-
cp /defaults/fail2ban/fail2ban.local /etc/fail2ban/
30-
cp /config/fail2ban/jail.local /etc/fail2ban/jail.local
14+
# copy/update the fail2ban config defaults to/in /config
15+
cp -R /defaults/fail2ban/filter.d /config/fail2ban/
16+
cp -R /defaults/fail2ban/action.d /config/fail2ban/
17+
# if jail.local is missing in /config, copy default
18+
if [[ ! -f /config/fail2ban/jail.local ]]; then
19+
cp /defaults/fail2ban/jail.local /config/fail2ban/jail.local
20+
fi
21+
# Replace fail2ban config with user config
22+
if [[ -d /etc/fail2ban/filter.d ]]; then
23+
rm -rf /etc/fail2ban/filter.d
24+
fi
25+
if [[ -d /etc/fail2ban/action.d ]]; then
26+
rm -rf /etc/fail2ban/action.d
27+
fi
28+
cp -R /config/fail2ban/filter.d /etc/fail2ban/
29+
cp -R /config/fail2ban/action.d /etc/fail2ban/
30+
cp /defaults/fail2ban/fail2ban.local /etc/fail2ban/
31+
cp /config/fail2ban/jail.local /etc/fail2ban/jail.local
3132

32-
# logfiles needed by fail2ban
33-
if [[ ! -f /config/log/nginx/error.log ]]; then
34-
touch /config/log/nginx/error.log
35-
fi
36-
if [[ ! -f /config/log/nginx/access.log ]]; then
37-
touch /config/log/nginx/access.log
33+
# logfiles needed by fail2ban
34+
if [[ ! -f /config/log/nginx/error.log ]]; then
35+
touch /config/log/nginx/error.log
36+
fi
37+
if [[ ! -f /config/log/nginx/access.log ]]; then
38+
touch /config/log/nginx/access.log
39+
fi
3840
fi

root/etc/s6-overlay/s6-rc.d/init-permissions-config/run

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# permissions
55
lsiown -R abc:abc \
66
/config
7-
chmod -R 0644 /etc/logrotate.d
87
chmod -R +r /config/log
98

109
# Workaround for systems with chmod errors

root/etc/s6-overlay/s6-rc.d/init-swag-folders/run

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ mkdir -p \
77
/config/etc/letsencrypt/renewal-hooks \
88
/config/log/{fail2ban,letsencrypt,nginx} \
99
/config/nginx/proxy-confs \
10-
/run/fail2ban
11-
rm -rf /etc/letsencrypt
12-
ln -s /config/etc/letsencrypt /etc/letsencrypt
10+
/run/fail2ban \
11+
/tmp/letsencrypt
12+
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/usr/bin/with-contenv bash
22
# shellcheck shell=bash
33

4-
exec \
5-
fail2ban-client -x -f start
4+
if [[ -z ${LSIO_READ_ONLY_FS} ]] && [[ -z ${LSIO_NON_ROOT_USER} ]] && [[ "${DISABLE_F2B,,}" != "true" ]]; then
5+
exec \
6+
fail2ban-client -x -f start
7+
else
8+
sleep infinity
9+
fi

0 commit comments

Comments
 (0)