Skip to content
This repository was archived by the owner on Jan 6, 2021. It is now read-only.

Commit 50eb108

Browse files
authored
Merge pull request #477 from linuxserver/ssl.conf-updates
Reformat ssl.conf
2 parents 3defc1d + 8b6715c commit 50eb108

File tree

7 files changed

+56
-42
lines changed

7 files changed

+56
-42
lines changed

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ RUN \
131131
/defaults/proxy-confs --strip-components=1 --exclude=linux*/.gitattributes --exclude=linux*/.github --exclude=linux*/.gitignore --exclude=linux*/LICENSE && \
132132
echo "**** configure nginx ****" && \
133133
rm -f /etc/nginx/conf.d/default.conf && \
134+
curl -o \
135+
/defaults/dhparams.pem -L \
136+
"https://lsio.ams3.digitaloceanspaces.com/dhparams.pem" && \
134137
echo "**** cleanup ****" && \
135138
apk del --purge \
136139
build-dependencies && \

Dockerfile.aarch64

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ RUN \
131131
/defaults/proxy-confs --strip-components=1 --exclude=linux*/.gitattributes --exclude=linux*/.github --exclude=linux*/.gitignore --exclude=linux*/LICENSE && \
132132
echo "**** configure nginx ****" && \
133133
rm -f /etc/nginx/conf.d/default.conf && \
134+
curl -o \
135+
/defaults/dhparams.pem -L \
136+
"https://lsio.ams3.digitaloceanspaces.com/dhparams.pem" && \
134137
echo "**** cleanup ****" && \
135138
apk del --purge \
136139
build-dependencies && \

Dockerfile.armhf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ RUN \
131131
/defaults/proxy-confs --strip-components=1 --exclude=linux*/.gitattributes --exclude=linux*/.github --exclude=linux*/.gitignore --exclude=linux*/LICENSE && \
132132
echo "**** configure nginx ****" && \
133133
rm -f /etc/nginx/conf.d/default.conf && \
134+
curl -o \
135+
/defaults/dhparams.pem -L \
136+
"https://lsio.ams3.digitaloceanspaces.com/dhparams.pem" && \
134137
echo "**** cleanup ****" && \
135138
apk del --purge \
136139
build-dependencies && \

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ docker create \
7474
-e PROPAGATION= `#optional` \
7575
-e DUCKDNSTOKEN= `#optional` \
7676
-e EMAIL= `#optional` \
77-
-e DHLEVEL=2048 `#optional` \
7877
-e ONLY_SUBDOMAINS=false `#optional` \
7978
-e EXTRA_DOMAINS= `#optional` \
8079
-e STAGING=false `#optional` \
@@ -110,7 +109,6 @@ services:
110109
- PROPAGATION= #optional
111110
- DUCKDNSTOKEN= #optional
112111
- EMAIL= #optional
113-
- DHLEVEL=2048 #optional
114112
- ONLY_SUBDOMAINS=false #optional
115113
- EXTRA_DOMAINS= #optional
116114
- STAGING=false #optional
@@ -140,7 +138,6 @@ Container images are configured using parameters passed at runtime (such as thos
140138
| `-e PROPAGATION=` | Optionally override (in seconds) the default propagation time for the dns plugins. |
141139
| `-e DUCKDNSTOKEN=` | Required if `VALIDATION` is set to `duckdns`. Retrieve your token from https://www.duckdns.org |
142140
| `-e EMAIL=` | Optional e-mail address used for cert expiration notifications. |
143-
| `-e DHLEVEL=2048` | Dhparams bit value (default=2048, can be set to `1024` or `4096`). |
144141
| `-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` |
145142
| `-e EXTRA_DOMAINS=` | Additional fully qualified domain names (comma separated, no spaces) ie. `extradomain.com,subdomain.anotherdomain.org` |
146143
| `-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. |
@@ -192,7 +189,8 @@ In this instance `PUID=1000` and `PGID=1000`, to find yours use `id user` as bel
192189
* After setup, navigate to `https://yourdomain.url` to access the default homepage (http access through port 80 is disabled by default, you can enable it by editing the default site config at `/config/nginx/site-confs/default`).
193190
* Certs are checked nightly and if expiration is within 30 days, renewal is attempted. If your cert is about to expire in less than 30 days, check the logs under `/config/log/letsencrypt` to see why the renewals have been failing. It is recommended to input your e-mail in docker parameters so you receive expiration notices from letsencrypt in those circumstances.
194191
### Security and password protection
195-
* The container detects changes to url and subdomains, revokes existing certs and generates new ones during start. It also detects changes to the DHLEVEL parameter and replaces the dhparams file.
192+
* The container detects changes to url and subdomains, revokes existing certs and generates new ones during start.
193+
* The container provides a pre-generated 4096-bit dhparams.pem (rotated weekly via [Jenkins job](https://ci.linuxserver.io/blue/organizations/jenkins/Xtras-Builders-Etc%2Fdhparams-uploader/activity)) for new instances, however you may generate your own by running `docker exec letsencrypt openssl dhparam -out /config/nginx/dhparams.pem 4096` WARNING: This takes a very long time
196194
* If you'd like to password protect your sites, you can use htpasswd. Run the following command on your host to generate the htpasswd file `docker exec -it letsencrypt htpasswd -c /config/nginx/.htpasswd <username>`
197195
* You can add multiple user:pass to `.htpasswd`. For the first user, use the above command, for others, use the above command without the `-c` flag, as it will force deletion of the existing `.htpasswd` and creation of a new one
198196
* You can also use ldap auth for security and access control. A sample, user configurable ldap.conf is provided, and it requires the separate image [linuxserver/ldap-auth](https://hub.docker.com/r/linuxserver/ldap-auth/) to communicate with an ldap server.
@@ -295,6 +293,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
295293

296294
## Versions
297295

296+
* **17.06.20:** - Reformat ssl.conf. Pull in pre-generated dhparams.pem from DO Spaces. Deprecate `DHLEVEL` param.
298297
* **01.06.20:** - Rebasing to alpine 3.12, change ldap login address to `/ldaplogin` to avoid clashes (existing users need to manually update).
299298
* **31.05.20:** - Tweak Authelia confs (existing users can delete `authelia-server.conf` and `authelia-location.conf`, and restart to update).
300299
* **23.05.20:** - Add support for Authelia.

readme-vars.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ opt_param_env_vars:
5555
- { env_var: "PROPAGATION", env_value: "", desc: "Optionally override (in seconds) the default propagation time for the dns plugins." }
5656
- { env_var: "DUCKDNSTOKEN", env_value: "", desc: "Required if `VALIDATION` is set to `duckdns`. Retrieve your token from https://www.duckdns.org" }
5757
- { env_var: "EMAIL", env_value: "", desc: "Optional e-mail address used for cert expiration notifications." }
58-
- { env_var: "DHLEVEL", env_value: "2048", desc: "Dhparams bit value (default=2048, can be set to `1024` or `4096`)." }
5958
- { 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`" }
6059
- { env_var: "EXTRA_DOMAINS", env_value: "", desc: "Additional fully qualified domain names (comma separated, no spaces) ie. `extradomain.com,subdomain.anotherdomain.org`" }
6160
- { 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." }
@@ -90,7 +89,8 @@ app_setup_block: |
9089
* After setup, navigate to `https://yourdomain.url` to access the default homepage (http access through port 80 is disabled by default, you can enable it by editing the default site config at `/config/nginx/site-confs/default`).
9190
* Certs are checked nightly and if expiration is within 30 days, renewal is attempted. If your cert is about to expire in less than 30 days, check the logs under `/config/log/letsencrypt` to see why the renewals have been failing. It is recommended to input your e-mail in docker parameters so you receive expiration notices from letsencrypt in those circumstances.
9291
### Security and password protection
93-
* The container detects changes to url and subdomains, revokes existing certs and generates new ones during start. It also detects changes to the DHLEVEL parameter and replaces the dhparams file.
92+
* The container detects changes to url and subdomains, revokes existing certs and generates new ones during start.
93+
* The container provides a pre-generated 4096-bit dhparams.pem (rotated weekly via [Jenkins job](https://ci.linuxserver.io/blue/organizations/jenkins/Xtras-Builders-Etc%2Fdhparams-uploader/activity)) for new instances, however you may generate your own by running `docker exec letsencrypt openssl dhparam -out /config/nginx/dhparams.pem 4096` WARNING: This takes a very long time
9494
* If you'd like to password protect your sites, you can use htpasswd. Run the following command on your host to generate the htpasswd file `docker exec -it letsencrypt htpasswd -c /config/nginx/.htpasswd <username>`
9595
* You can add multiple user:pass to `.htpasswd`. For the first user, use the above command, for others, use the above command without the `-c` flag, as it will force deletion of the existing `.htpasswd` and creation of a new one
9696
* You can also use ldap auth for security and access control. A sample, user configurable ldap.conf is provided, and it requires the separate image [linuxserver/ldap-auth](https://hub.docker.com/r/linuxserver/ldap-auth/) to communicate with an ldap server.
@@ -127,6 +127,7 @@ app_setup_nginx_reverse_proxy_block: ""
127127

128128
# changelog
129129
changelogs:
130+
- { date: "17.06.20:", desc: "Reformat ssl.conf. Pull in pre-generated dhparams.pem from DO Spaces. Deprecate `DHLEVEL` param." }
130131
- { date: "01.06.20:", desc: "Rebasing to alpine 3.12, change ldap login address to `/ldaplogin` to avoid clashes (existing users need to manually update)." }
131132
- { date: "31.05.20:", desc: "Tweak Authelia confs (existing users can delete `authelia-server.conf` and `authelia-location.conf`, and restart to update)." }
132133
- { date: "23.05.20:", desc: "Add support for Authelia." }

root/defaults/ssl.conf

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,43 @@
1-
## Version 2020/01/07 - Changelog: https://github.com/linuxserver/docker-letsencrypt/commits/master/root/defaults/ssl.conf
1+
## Version 2020/06/17 - Changelog: https://github.com/linuxserver/docker-letsencrypt/commits/master/root/defaults/ssl.conf
2+
3+
### Mozilla Recommendations
4+
# generated 2020-06-17, Mozilla Guideline v5.4, nginx 1.18.0-r0, OpenSSL 1.1.1g-r0, intermediate configuration
5+
# https://ssl-config.mozilla.org/#server=nginx&version=1.18.0-r0&config=intermediate&openssl=1.1.1g-r0&guideline=5.4
26

3-
# session settings
47
ssl_session_timeout 1d;
5-
ssl_session_cache shared:SSL:50m;
8+
ssl_session_cache shared:MozSSL:10m; # about 40000 sessions
69
ssl_session_tickets off;
710

8-
# Diffie-Hellman parameter for DHE cipher suites
9-
ssl_dhparam /config/nginx/dhparams.pem;
10-
11-
# ssl certs
12-
ssl_certificate /config/keys/letsencrypt/fullchain.pem;
13-
ssl_certificate_key /config/keys/letsencrypt/privkey.pem;
14-
15-
# protocols
16-
# using generated 2020-01-07, https://ssl-config.mozilla.org/#server=nginx&server-version=1.16.1-r4&config=intermediate&openssl-version=1.1.1d-r3
11+
# intermediate configuration
1712
ssl_protocols TLSv1.2 TLSv1.3;
1813
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
1914
ssl_prefer_server_ciphers off;
2015

21-
# HSTS, remove # from the line below to enable HSTS
22-
#add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
23-
24-
# OCSP Stapling
16+
# OCSP stapling
2517
ssl_stapling on;
2618
ssl_stapling_verify on;
19+
20+
21+
### Linuxserver.io Defaults
22+
23+
# Certificates
24+
ssl_certificate /config/keys/letsencrypt/fullchain.pem;
25+
ssl_certificate_key /config/keys/letsencrypt/privkey.pem;
26+
# verify chain of trust of OCSP response using Root CA and Intermediate certs
27+
ssl_trusted_certificate /config/keys/letsencrypt/fullchain.pem;
28+
29+
# Diffie-Hellman Parameters
30+
ssl_dhparam /config/nginx/dhparams.pem;
31+
32+
# Resolver
2733
resolver 127.0.0.11 valid=30s; # Docker DNS Server
2834

2935
# Enable TLS 1.3 early data
3036
ssl_early_data on;
3137

38+
# HSTS, remove # from the line below to enable HSTS
39+
#add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
40+
3241
# Optional additional headers
3342
#add_header Content-Security-Policy "upgrade-insecure-requests";
3443
#add_header X-Frame-Options "SAMEORIGIN" always;

root/etc/cont-init.d/50-config

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ URL=${URL}\\n\
99
SUBDOMAINS=${SUBDOMAINS}\\n\
1010
EXTRA_DOMAINS=${EXTRA_DOMAINS}\\n\
1111
ONLY_SUBDOMAINS=${ONLY_SUBDOMAINS}\\n\
12-
DHLEVEL=${DHLEVEL}\\n\
1312
VALIDATION=${VALIDATION}\\n\
1413
DNSPLUGIN=${DNSPLUGIN}\\n\
1514
EMAIL=${EMAIL}\\n\
@@ -21,7 +20,7 @@ if [ -n "${TEST_RUN}" ]; then
2120
fi
2221

2322
# Sanitize variables
24-
SANED_VARS=( DHLEVEL DNSPLUGIN EMAIL EXTRA_DOMAINS ONLY_SUBDOMAINS STAGING SUBDOMAINS URL VALIDATION )
23+
SANED_VARS=( DNSPLUGIN EMAIL EXTRA_DOMAINS ONLY_SUBDOMAINS STAGING SUBDOMAINS URL VALIDATION )
2524
for i in "${SANED_VARS[@]}"
2625
do
2726
export echo "$i"="${!i//\"/}"
@@ -46,8 +45,8 @@ chown -R abc:abc /config/dns-conf
4645

4746
# copy reverse proxy configs
4847
cp -R /defaults/proxy-confs /config/nginx/
49-
# remove outdated files (remove this action after 2019/08/29)
50-
rm -f /config/nginx/proxy-confs/_readme /config/nginx/proxy-confs/mytinytodo.subfolder.conf.example
48+
# remove outdated files (remove this action after 2020/10/17)
49+
rm -f /config/nginx/proxy-confs/seafile.subdomain.config.sample /config/nginx/proxy-confs/librespeed.subdomain.com.sample
5150

5251
# copy/update the fail2ban config defaults to/in /config
5352
cp -R /defaults/fail2ban/filter.d /config/fail2ban/
@@ -79,6 +78,17 @@ cp /config/fail2ban/jail.local /etc/fail2ban/jail.local
7978
[[ ! -f /config/nginx/authelia-location.conf ]] && \
8079
cp /defaults/authelia-location.conf /config/nginx/authelia-location.conf
8180

81+
# copy pre-generated dhparams or generate if needed
82+
[[ ! -f /config/nginx/dhparams.pem ]] && \
83+
cp /defaults/dhparams.pem /config/nginx/dhparams.pem
84+
if ! grep -q 'PARAMETERS' "/config/nginx/dhparams.pem"; then
85+
curl -o /config/nginx/dhparams.pem -L "https://lsio.ams3.digitaloceanspaces.com/dhparams.pem"
86+
fi
87+
if ! grep -q 'PARAMETERS' "/config/nginx/dhparams.pem"; then
88+
echo "Generating dhparams.pem. This will take a long time. Do not stop the container until this process is completed."
89+
openssl dhparam -out /config/nginx/dhparams.pem 4096
90+
fi
91+
8292
# check to make sure DNSPLUGIN is selected if dns validation is used
8393
[[ "$VALIDATION" = "dns" ]] && [[ ! "$DNSPLUGIN" =~ ^(aliyun|cloudflare|cloudxns|cpanel|digitalocean|dnsimple|dnsmadeeasy|domeneshop|gandi|google|inwx|linode|luadns|nsone|ovh|rfc2136|route53|transip)$ ]] && \
8494
echo "Please set the DNSPLUGIN variable to a valid plugin name. See docker info for more details." && \
@@ -90,7 +100,7 @@ cp /config/crontabs/* /etc/crontabs/
90100

91101
# create original config file if it doesn't exist
92102
if [ ! -f "/config/donoteditthisfile.conf" ]; then
93-
echo -e "ORIGURL=\"$URL\" ORIGSUBDOMAINS=\"$SUBDOMAINS\" ORIGONLY_SUBDOMAINS=\"$ONLY_SUBDOMAINS\" ORIGEXTRA_DOMAINS=\"$EXTRA_DOMAINS\" ORIGDHLEVEL=\"$DHLEVEL\" ORIGVALIDATION=\"$VALIDATION\" ORIGDNSPLUGIN=\"$DNSPLUGIN\" ORIGPROPAGATION=\"$PROPAGATION\" ORIGSTAGING=\"$STAGING\" ORIGDUCKDNSTOKEN=\"$DUCKDNSTOKEN\"" > /config/donoteditthisfile.conf
103+
echo -e "ORIGURL=\"$URL\" ORIGSUBDOMAINS=\"$SUBDOMAINS\" ORIGONLY_SUBDOMAINS=\"$ONLY_SUBDOMAINS\" ORIGEXTRA_DOMAINS=\"$EXTRA_DOMAINS\" ORIGVALIDATION=\"$VALIDATION\" ORIGDNSPLUGIN=\"$DNSPLUGIN\" ORIGPROPAGATION=\"$PROPAGATION\" ORIGSTAGING=\"$STAGING\" ORIGDUCKDNSTOKEN=\"$DUCKDNSTOKEN\"" > /config/donoteditthisfile.conf
94104
echo "Created donoteditthisfile.conf"
95105
fi
96106

@@ -104,12 +114,6 @@ if [ -z "$VALIDATION" ]; then
104114
echo "VALIDATION parameter not set; setting it to http"
105115
fi
106116

107-
# compare dhparams existence and level, create if necessary
108-
if [ ! "$DHLEVEL" = "$ORIGDHLEVEL" ]; then
109-
rm -rf /config/nginx/dhparams.pem
110-
echo "DH parameters bit setting changed. Deleting old dhparams file."
111-
fi
112-
113117
# if staging is set to true, use the staging server
114118
if [ "$STAGING" = "true" ]; then
115119
echo "NOTICE: Staging is active"
@@ -118,14 +122,6 @@ else
118122
ACMESERVER="https://acme-v02.api.letsencrypt.org/directory"
119123
fi
120124

121-
if [ ! -f "/config/nginx/dhparams.pem" ]; then
122-
echo "Creating DH parameters for additional security. This may take a very long time. There will be another message once this process is completed"
123-
openssl dhparam -out /config/nginx/dhparams.pem "$DHLEVEL"
124-
echo "DH parameters successfully created - $DHLEVEL bits"
125-
else
126-
echo "$ORIGDHLEVEL bit DH parameters present"
127-
fi
128-
129125
# figuring out url only vs url & subdomains vs subdomains only
130126
if [ -n "$SUBDOMAINS" ]; then
131127
echo "SUBDOMAINS entered, processing"
@@ -238,7 +234,7 @@ if [ ! "$URL" = "$ORIGURL" ] || [ ! "$SUBDOMAINS" = "$ORIGSUBDOMAINS" ] || [ ! "
238234
fi
239235

240236
# saving new variables
241-
echo -e "ORIGURL=\"$URL\" ORIGSUBDOMAINS=\"$SUBDOMAINS\" ORIGONLY_SUBDOMAINS=\"$ONLY_SUBDOMAINS\" ORIGEXTRA_DOMAINS=\"$EXTRA_DOMAINS\" ORIGDHLEVEL=\"$DHLEVEL\" ORIGVALIDATION=\"$VALIDATION\" ORIGDNSPLUGIN=\"$DNSPLUGIN\" ORIGPROPAGATION=\"$PROPAGATION\" ORIGSTAGING=\"$STAGING\" ORIGDUCKDNSTOKEN=\"$DUCKDNSTOKEN\"" > /config/donoteditthisfile.conf
237+
echo -e "ORIGURL=\"$URL\" ORIGSUBDOMAINS=\"$SUBDOMAINS\" ORIGONLY_SUBDOMAINS=\"$ONLY_SUBDOMAINS\" ORIGEXTRA_DOMAINS=\"$EXTRA_DOMAINS\" ORIGVALIDATION=\"$VALIDATION\" ORIGDNSPLUGIN=\"$DNSPLUGIN\" ORIGPROPAGATION=\"$PROPAGATION\" ORIGSTAGING=\"$STAGING\" ORIGDUCKDNSTOKEN=\"$DUCKDNSTOKEN\"" > /config/donoteditthisfile.conf
242238

243239
# alter extension for error message
244240
if [ "$DNSPLUGIN" = "google" ]; then

0 commit comments

Comments
 (0)