Skip to content

Commit 8219788

Browse files
authored
Merge branch 'master' into master
2 parents f68383a + 941fd63 commit 8219788

16 files changed

+189
-97
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ env:
77
- TEST_TARGET: test-alpine
88

99
before_install:
10-
- sudo apt-get remove docker docker-engine
10+
- sudo apt-get -y remove docker docker-engine docker-ce
11+
- sudo rm /etc/apt/sources.list.d/docker.list
1112
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
1213
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
1314
- sudo apt-get update

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM nginx:1.13
1+
FROM nginx:1.17.8
22
LABEL maintainer="Jason Wilder [email protected]"
33

44
# Install wget and install/updates certificates

Dockerfile.alpine

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM nginx:1.13-alpine
1+
FROM nginx:1.17.8-alpine
22
LABEL maintainer="Jason Wilder [email protected]"
33

44
# Install wget and install/updates certificates

README.md

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
![latest 0.7.0](https://img.shields.io/badge/latest-0.7.0-green.svg?style=flat)
2-
![nginx 1.13](https://img.shields.io/badge/nginx-1.13-brightgreen.svg) ![License MIT](https://img.shields.io/badge/license-MIT-blue.svg) [![Build Status](https://travis-ci.org/jwilder/nginx-proxy.svg?branch=master)](https://travis-ci.org/jwilder/nginx-proxy) [![](https://img.shields.io/docker/stars/jwilder/nginx-proxy.svg)](https://hub.docker.com/r/jwilder/nginx-proxy 'DockerHub') [![](https://img.shields.io/docker/pulls/jwilder/nginx-proxy.svg)](https://hub.docker.com/r/jwilder/nginx-proxy 'DockerHub')
2+
![nginx 1.17.8](https://img.shields.io/badge/nginx-1.17.8-brightgreen.svg) ![License MIT](https://img.shields.io/badge/license-MIT-blue.svg) [![Build Status](https://travis-ci.org/jwilder/nginx-proxy.svg?branch=master)](https://travis-ci.org/jwilder/nginx-proxy) [![](https://img.shields.io/docker/stars/jwilder/nginx-proxy.svg)](https://hub.docker.com/r/jwilder/nginx-proxy 'DockerHub') [![](https://img.shields.io/docker/pulls/jwilder/nginx-proxy.svg)](https://hub.docker.com/r/jwilder/nginx-proxy 'DockerHub')
33

44

55
nginx-proxy sets up a container running nginx and [docker-gen][1]. docker-gen generates reverse proxy configs for nginx and reloads nginx when containers are started and stopped.
@@ -16,7 +16,7 @@ Then start any containers you want proxied with an env var `VIRTUAL_HOST=subdoma
1616

1717
$ docker run -e VIRTUAL_HOST=foo.bar.com ...
1818

19-
The containers being proxied must [expose](https://docs.docker.com/engine/reference/run/#expose-incoming-ports) the port to be proxied, either by using the `EXPOSE` directive in their `Dockerfile` or by using the `--expose` flag to `docker run` or `docker create`.
19+
The containers being proxied must [expose](https://docs.docker.com/engine/reference/run/#expose-incoming-ports) the port to be proxied, either by using the `EXPOSE` directive in their `Dockerfile` or by using the `--expose` flag to `docker run` or `docker create` and be in the same network. By default, if you don't pass the --net flag when your nginx-proxy container is created, it will only be attached to the default bridge network. This means that it will not be able to connect to containers on networks other than bridge.
2020

2121
Provided your DNS is setup to forward foo.bar.com to the host running nginx-proxy, the request will be routed to a container with the VIRTUAL_HOST env var set.
2222

@@ -133,7 +133,7 @@ If you would like to connect to FastCGI backend, set `VIRTUAL_PROTO=fastcgi` on
133133
backend container. Your backend container should then listen on a port rather
134134
than a socket and expose that port.
135135

136-
### FastCGI Filr Root Directory
136+
### FastCGI File Root Directory
137137

138138
If you use fastcgi,you can set `VIRTUAL_ROOT=xxx` for your root directory
139139

@@ -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 allows 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`.
@@ -237,20 +241,27 @@ to identify the certificate to be used. For example, a certificate for `*.foo.c
237241
could be named `shared.crt` and `shared.key`. A container running with `VIRTUAL_HOST=foo.bar.com`
238242
and `CERT_NAME=shared` will then use this shared cert.
239243

244+
#### OCSP Stapling
245+
To enable OCSP Stapling for a domain, `nginx-proxy` looks for a PEM certificate containing the trusted
246+
CA certificate chain at `/etc/nginx/certs/<domain>.chain.pem`, where `<domain>` is the domain name in
247+
the `VIRTUAL_HOST` directive. The format of this file is a concatenation of the public PEM CA
248+
certificates starting with the intermediate CA most near the SSL certificate, down to the root CA. This is
249+
often referred to as the "SSL Certificate Chain". If found, this filename is passed to the NGINX
250+
[`ssl_trusted_certificate` directive](http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_trusted_certificate)
251+
and OCSP Stapling is enabled.
252+
240253
#### How SSL Support Works
241254

242-
The default SSL cipher configuration is based on the [Mozilla intermediate profile](https://wiki.mozilla.org/Security/Server_Side_TLS#Intermediate_compatibility_.28default.29) which
243-
should provide compatibility with clients back to Firefox 1, Chrome 1, IE 7, Opera 5, Safari 1,
244-
Windows XP IE8, Android 2.3, Java 7. Note that the DES-based TLS ciphers were removed for security.
245-
The configuration also enables HSTS, PFS, OCSP stapling and SSL session caches. Currently TLS 1.0, 1.1 and 1.2
246-
are supported. TLS 1.0 is deprecated but its end of life is not until June 30, 2018. It is being
247-
included because the following browsers will stop working when it is removed: Chrome < 22, Firefox < 27,
248-
IE < 11, Safari < 7, iOS < 5, Android Browser < 5.
255+
The default SSL cipher configuration is based on the [Mozilla intermediate profile](https://wiki.mozilla.org/Security/Server_Side_TLS#Intermediate_compatibility_.28recommended.29) version 5.0 which
256+
should provide compatibility with clients back to Firefox 27, Android 4.4.2, Chrome 31, Edge, IE 11 on Windows 7,
257+
Java 8u31, OpenSSL 1.0.1, Opera 20, and Safari 9. Note that the DES-based TLS ciphers were removed for security.
258+
The configuration also enables HSTS, PFS, OCSP stapling and SSL session caches. Currently TLS 1.2 and 1.3
259+
are supported.
249260

250261
If you don't require backward compatibility, you can use the [Mozilla modern profile](https://wiki.mozilla.org/Security/Server_Side_TLS#Modern_compatibility)
251-
profile instead by including the environment variable `SSL_POLICY=Mozilla-Modern` to your container.
252-
This profile is compatible with clients back to Firefox 27, Chrome 30, IE 11 on Windows 7,
253-
Edge, Opera 17, Safari 9, Android 5.0, and Java 8.
262+
profile instead by including the environment variable `SSL_POLICY=Mozilla-Modern` to the nginx-proxy container or to your container.
263+
This profile is compatible with clients back to Firefox 63, Android 10.0, Chrome 70, Edge 75, Java 11,
264+
OpenSSL 1.1.1, Opera 57, and Safari 12.1. Note that this profile is **not** compatible with any version of Internet Explorer.
254265

255266
Other policies available through the `SSL_POLICY` environment variable are [`Mozilla-Old`](https://wiki.mozilla.org/Security/Server_Side_TLS#Old_backward_compatibility)
256267
and the [AWS ELB Security Policies](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-security-policy-table.html)
@@ -273,12 +284,12 @@ a 500.
273284

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

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

403414
docker build -t jwilder/nginx-proxy:test . # build the Debian variant image
404-
415+
405416
and call the [test/pytest.sh](test/pytest.sh) script.
406417

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

416427
make test
417-
428+
418429

419430
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.
420431

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: 8 additions & 1 deletion
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.
@@ -37,7 +43,8 @@ touch $GEN_LOCKFILE
3743
# Generate a new dhparam in the background in a low priority and reload nginx when finished (grep removes the progress indicator).
3844
(
3945
(
40-
nice -n +5 openssl dhparam -out $DHPARAM_FILE $DHPARAM_BITS 2>&1 \
46+
nice -n +5 openssl dhparam -out $DHPARAM_FILE.tmp $DHPARAM_BITS 2>&1 \
47+
&& mv $DHPARAM_FILE.tmp $DHPARAM_FILE \
4148
&& echo "dhparam generation complete, reloading nginx" \
4249
&& nginx -s reload
4350
) | grep -vE '^[\.+]+'

0 commit comments

Comments
 (0)