Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify the use of custom NGINX SSL certificates with Docker Compose #11504

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Dockerfile.nginx-alpine
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,11 @@ RUN env DD_SECRET_KEY='.' python3 manage.py collectstatic --noinput && true
FROM nginx:1.27.3-alpine@sha256:41523187cf7d7a2f2677a80609d9caa14388bf5c1fbca9c410ba3de602aaaab4
ARG uid=1001
ARG appuser=defectdojo
ARG NGINX_CRT_PATH=""
ARG NGINX_KEY_PATH=""
COPY --from=collectstatic /app/static/ /usr/share/nginx/html/static/
COPY wsgi_params nginx/nginx.conf nginx/nginx_TLS.conf /etc/nginx/
COPY ${NGINX_CRT_PATH} ${NGINX_KEY_PATH} /etc/nginx/ssl/
COPY docker/entrypoint-nginx.sh /
RUN \
apk add --no-cache openssl && \
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile.nginx-debian
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,11 @@ RUN env DD_SECRET_KEY='.' python3 manage.py collectstatic --noinput && true
FROM nginx:1.27.3-alpine@sha256:41523187cf7d7a2f2677a80609d9caa14388bf5c1fbca9c410ba3de602aaaab4
ARG uid=1001
ARG appuser=defectdojo
ARG NGINX_CRT_PATH=""
ARG NGINX_KEY_PATH=""
COPY --from=collectstatic /app/static/ /usr/share/nginx/html/static/
COPY wsgi_params nginx/nginx.conf nginx/nginx_TLS.conf /etc/nginx/
COPY ${NGINX_CRT_PATH} ${NGINX_KEY_PATH} /etc/nginx/ssl/
COPY docker/entrypoint-nginx.sh /
RUN \
apk add --no-cache openssl && \
Expand Down
11 changes: 8 additions & 3 deletions docker-compose.override.https.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
---
services:
nginx:
build:
context: .
args:
NGINX_CRT_PATH: ''
NGINX_KEY_PATH: ''
environment:
USE_TLS: 'true'
GENERATE_TLS_CERTIFICATE: 'true'
Expand All @@ -10,6 +15,6 @@ services:
protocol: tcp
mode: host
uwsgi:
environment:
DD_SESSION_COOKIE_SECURE: 'True'
DD_CSRF_COOKIE_SECURE: 'True'
environment:
DD_SESSION_COOKIE_SECURE: 'True'
DD_CSRF_COOKIE_SECURE: 'True'
16 changes: 13 additions & 3 deletions readme-docs/DOCKER.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,24 @@ To secure the application by https, follow those steps
* Generate a private key without password
* Generate a CSR (Certificate Signing Request)
* Have the CSR signed by a certificate authority
* Place the private key and the certificate under the nginx folder
* copy your secrets into ../nginx/nginx_TLS.conf:
* Place the private key and the certificate under the `nginx/` folder
* copy your secrets into `../nginx/nginx_TLS.conf`:
```
server_name your.servername.com;
ssl_certificate /etc/nginx/ssl/nginx.crt
ssl_certificate_key /etc/nginx/ssl/nginx.key;
```
*set the GENERATE_TLS_CERTIFICATE != True in the docker-compose.override.https.yml
* set in the `docker-compose.override.https.yml`
```
GENERATE_TLS_CERTIFICATE: 'false'
```
* set in the `docker-compose.override.https.yml`
```
NGINX_CRT_PATH: 'nginx/nginx.crt'
NGINX_KEY_PATH: 'nginx/nginx.key'
```
*or leave both empty if GENERATE_TLS_CERTIFICATE = true

* Protect your private key from other users:
```
chmod 400 nginx/*.key
Expand Down
Loading