Skip to content

Commit 8c590fc

Browse files
authored
Merge pull request nginx-proxy#913 from panteparak/DH-Param-Generator-Option
Add DH param generator option
2 parents 15d2817 + 92379d8 commit 8c590fc

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,12 @@ Finally, start your containers with `VIRTUAL_HOST` environment variables.
181181
$ docker run -e VIRTUAL_HOST=foo.bar.com ...
182182
### SSL Support using letsencrypt
183183

184-
[letsencrypt-nginx-proxy-companion](https://github.com/JrCs/docker-letsencrypt-nginx-proxy-companion) is a lightweight companion container for the nginx-proxy. It allow the creation/renewal of Let's Encrypt certificates automatically.
184+
[letsencrypt-nginx-proxy-companion](https://github.com/JrCs/docker-letsencrypt-nginx-proxy-companion) is a lightweight companion container for the nginx-proxy. It allow the creation/renewal of Let's Encrypt certificates automatically.
185185

186+
Set `DHPARAM_GENERATION` environment variable to `false` to disabled Diffie-Hellman parameters completely. This will also ignore auto-generation made by `nginx-proxy`.
187+
The default value is `true`
188+
189+
$ docker run -e DHPARAM_GENERATION=false ....
186190
### SSL Support
187191

188192
SSL is supported using single host, wildcard and SNI certificates using naming conventions for
@@ -214,7 +218,7 @@ at startup. Since it can take minutes to generate a new `dhparam.pem`, it is do
214218
background. Once generation is complete, the `dhparam.pem` is saved on a persistent volume and nginx
215219
is reloaded. This generation process only occurs the first time you start `nginx-proxy`.
216220

217-
> COMPATIBILITY WARNING: The default generated `dhparam.pem` key is 2048 bits for A+ security. Some
221+
> COMPATIBILITY WARNING: The default generated `dhparam.pem` key is 2048 bits for A+ security. Some
218222
> older clients (like Java 6 and 7) do not support DH keys with over 1024 bits. In order to support these
219223
> clients, you must either provide your own `dhparam.pem`, or tell `nginx-proxy` to generate a 1024-bit
220224
> key on startup by passing `-e DHPARAM_BITS=1024`.
@@ -282,12 +286,12 @@ a 500.
282286

283287
To serve traffic in both SSL and non-SSL modes without redirecting to SSL, you can include the
284288
environment variable `HTTPS_METHOD=noredirect` (the default is `HTTPS_METHOD=redirect`). You can also
285-
disable the non-SSL site entirely with `HTTPS_METHOD=nohttp`, or disable the HTTPS site with
286-
`HTTPS_METHOD=nohttps`. `HTTPS_METHOD` must be specified on each container for which you want to
287-
override the default behavior. If `HTTPS_METHOD=noredirect` is used, Strict Transport Security (HSTS)
288-
is disabled to prevent HTTPS users from being redirected by the client. If you cannot get to the HTTP
289-
site after changing this setting, your browser has probably cached the HSTS policy and is automatically
290-
redirecting you back to HTTPS. You will need to clear your browser's HSTS cache or use an incognito
289+
disable the non-SSL site entirely with `HTTPS_METHOD=nohttp`, or disable the HTTPS site with
290+
`HTTPS_METHOD=nohttps`. `HTTPS_METHOD` must be specified on each container for which you want to
291+
override the default behavior. If `HTTPS_METHOD=noredirect` is used, Strict Transport Security (HSTS)
292+
is disabled to prevent HTTPS users from being redirected by the client. If you cannot get to the HTTP
293+
site after changing this setting, your browser has probably cached the HSTS policy and is automatically
294+
redirecting you back to HTTPS. You will need to clear your browser's HSTS cache or use an incognito
291295
window / different browser.
292296

293297
By default, [HTTP Strict Transport Security (HSTS)](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security)
@@ -410,7 +414,7 @@ Before submitting pull requests or issues, please check github to make sure an e
410414
To run tests, you need to prepare the docker image to test which must be tagged `jwilder/nginx-proxy:test`:
411415

412416
docker build -t jwilder/nginx-proxy:test . # build the Debian variant image
413-
417+
414418
and call the [test/pytest.sh](test/pytest.sh) script.
415419

416420
Then build the Alpine variant of the image:
@@ -423,7 +427,7 @@ and call the [test/pytest.sh](test/pytest.sh) script again.
423427
If your system has the `make` command, you can automate those tasks by calling:
424428

425429
make test
426-
430+
427431

428432
You can learn more about how the test suite works and how to write new tests in the [test/README.md](test/README.md) file.
429433

docker-entrypoint.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ fi
1616

1717
# Generate dhparam file if required
1818
# Note: if $DHPARAM_BITS is not defined, generate-dhparam.sh will use 2048 as a default
19-
/app/generate-dhparam.sh $DHPARAM_BITS
19+
# Note2: if $DHPARAM_GENERATION is set to false in environment variable, dh param generator will skip completely
20+
/app/generate-dhparam.sh $DHPARAM_BITS $DHPARAM_GENERATION
2021

2122
# Compute the DNS resolvers for use in the templates - if the IP contains ":", it's IPv6 and must be enclosed in []
2223
export RESOLVERS=$(awk '$1 == "nameserver" {print ($2 ~ ":")? "["$2"]": $2}' ORS=' ' /etc/resolv.conf | sed 's/ *$//g')

generate-dhparam.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# The first argument is the bit depth of the dhparam, or 2048 if unspecified
44
DHPARAM_BITS=${1:-2048}
5+
GENERATE_DHPARAM=${2:-true}
56

67
# If a dhparam file is not available, use the pre-generated one and generate a new one in the background.
78
# Note that /etc/nginx/dhparam is a volume, so this dhparam will persist restarts.
@@ -25,6 +26,11 @@ if [[ -f $DHPARAM_FILE ]]; then
2526
fi
2627
fi
2728

29+
if [[ $GENERATE_DHPARAM =~ ^[Ff][Aa][Ll][Ss][Ee]$ ]]; then
30+
echo "Skipping Diffie-Hellman parameters generation and Ignoring pre-generated dhparam.pem"
31+
exit 0
32+
fi
33+
2834
cat >&2 <<-EOT
2935
WARNING: $DHPARAM_FILE was not found. A pre-generated dhparam.pem will be used for now while a new one
3036
is being generated in the background. Once the new dhparam.pem is in place, nginx will be reloaded.

0 commit comments

Comments
 (0)