Skip to content

Commit 39f3238

Browse files
committed
Temporarily require that the Nginx server generates a self-signed TLS certificate for testing purposes.
1 parent 33368f8 commit 39f3238

File tree

7 files changed

+40
-18
lines changed

7 files changed

+40
-18
lines changed

docker-compose.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,16 @@ services:
6767
context: docker/nginx/
6868
image: tec-proxy:latest
6969
container_name: tec-proxy
70+
environment:
71+
SERVER_NAME: encryptioncompendium.org
7072
ports:
7173
- "80:80"
7274
- "443:443"
7375
volumes:
7476
# Shared volume with the gunicorn server that allows us to
7577
# serve static files.
7678
- staticfiles:/opt/services/tec-gunicorn/static:ro
77-
- letsencrypt:/etc/letsencrypt:rw
79+
- letsencrypt:/tls:rw
7880
depends_on:
7981
- gunicorn
8082
networks:

docker/nginx/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,11 @@ RUN adduser -D -s /bin/false -G www-data www-data
1010

1111
# Create directory for caching
1212
RUN mkdir -p /data/nginx/cache
13+
14+
RUN apk update \
15+
&& apk add --no-cache openssl \
16+
&& mkdir -p /tls/encryptioncompendium.org/
17+
18+
# Add a custom run script
19+
COPY run.sh /run.sh
20+
CMD [ "/run.sh" ]

docker/nginx/conf.d/https renamed to docker/nginx/conf.d/default.conf

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,11 @@ server {
1414
client_max_body_size 4G;
1515
server_name _;
1616

17-
#ssl_certificate ${SSL_CERT};
18-
#ssl_certificate_key ${SSL_KEY};
17+
ssl_certificate /tls/fullchain.pem;
18+
ssl_certificate_key /tls/privkey.pem;
1919

2020
keepalive_timeout 70;
2121

22-
# Absolute path to site
23-
root /var/www/public/;
24-
index index.html;
25-
2622
location / {
2723
# everything is passed to Gunicorn
2824
proxy_pass http://encryption_compendium_server;

docker/nginx/conf.d/http

Lines changed: 0 additions & 9 deletions
This file was deleted.

docker/nginx/conf.d/http.conf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Automatically redirect all http traffic to https
2+
server {
3+
listen 80 default_server;
4+
listen [::]:80 default_server;
5+
6+
server_name _;
7+
8+
return 302 https://$host$request_uri;
9+
}

docker/nginx/nginx.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ http {
3030
ssl_prefer_server_ciphers on;
3131

3232
# Logging
33-
access_log /var/log/nginx/access.log;
34-
error_log /var/log/nginx/error.log;
33+
#access_log /var/log/nginx/access.log;
34+
#error_log /var/log/nginx/error.log;
3535

3636
# Virtual host configs
3737
include /etc/nginx/conf.d/*.conf;

docker/nginx/run.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
# Generate self-signed TLS certificates
4+
if [ ! -f /tls/fullchain.pem ]
5+
then
6+
openssl req \
7+
-x509 \
8+
-newkey rsa:4096 \
9+
-keyout /tls/privkey.pem \
10+
-out /tls/fullchain.pem \
11+
-days 30 \
12+
-nodes \
13+
-subj "/CN=${SERVER_NAME}"
14+
fi
15+
16+
nginx -g 'daemon off;'

0 commit comments

Comments
 (0)