Skip to content

Commit 2e6eabb

Browse files
committed
devops: revise TLS key setup procedure
Allow setting TLS/SSL key URIs using environment variables, export the URIs as NUMWAL_TLS_PUBLIC_KEY_URI and NUMWAL_TLS_PRIVATE_KEY_URI on the host before building containers Update tls/ directory structure Update SETUP.md
1 parent 7d315af commit 2e6eabb

File tree

6 files changed

+23
-13
lines changed

6 files changed

+23
-13
lines changed

SETUP.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ The following settings may be altered without editing any project or
139139
configuration files, by exporting these environment variables on
140140
the host:
141141

142+
* `NUMWAL_TLS_PRIVATE_KEY_URI`: use this variable to change the URI
143+
to the private key in the Nginx server.
144+
145+
* `NUMWAL_TLS_PUBLIC_KEY_URI`: use this variable to change the URI
146+
to the public key certificate in the Nginx server.
147+
142148
* `NUMWAL_CACHE_CLEAR`: set to any integer 1 or higher to order the
143149
underlying Fat Free Framework to clear caches.
144150

compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ services:
4747
NUMWAL_HTTP_PORT: 8080
4848
NUMWAL_HTTPS_PORT: 443
4949
NUMWAL_HOST: numwal
50+
NUMWAL_TLS_PUBLIC_KEY_URI: ${NUMWAL_TLS_PUBLIC_KEY_URI:-/etc/ssl/keys/numwal-cert.pem}
51+
NUMWAL_TLS_PRIVATE_KEY_URI: ${NUMWAL_TLS_PRIVATE_KEY_URI:-/etc/ssl/private/numwal-private.pem}
5052
ports:
5153
- 9080:8080
5254
- 9443:443

conf/numwal-with-tls.conf.template

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ server {
2020
listen [::]:${NUMWAL_HTTPS_PORT} ssl;
2121

2222
# Remember to change the certificate and private key filenames as required
23-
ssl_certificate /etc/ssl/keys/numwal-cert.pem;
24-
ssl_certificate_key /etc/ssl/private/numwal-private.pem;
25-
23+
ssl_certificate ${NUMWAL_TLS_PUBLIC_KEY_URI};
24+
ssl_certificate_key ${NUMWAL_TLS_PRIVATE_KEY_URI};
25+
2626
location / {
2727
index index.php index.html index.htm;
2828
try_files $uri /index.php?query_string;

tls/README-tls.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
# TLS Certificate and Private Key Directory
22

3-
Place your certificate and private key in this directory, so the image build
4-
process can find them and insert them into your image.
3+
Place your public key certificate in the `keys/` directory, and your
4+
private key in the `private/` directory. Please do this only for
5+
self-signed test keys.
56

6-
The Dockerfile expects your certificate (public key) to be named `numwal.pem`
7-
and your private key to be named `numwal-private.pem`.
7+
The key URIs may be set using the `NUMWAL_TLS_PUBLIC_KEY_URI` and
8+
`NUMWAL_TLS_PRIVATE_KEY_URI` environment variables on the host before
9+
building the containers.
810

9-
If you wish to use different names for keys, and/or source them from another
10-
path, please keep the Dockerfile `Dockerfile-nginx-tls` and the Nginx
11-
configuration file `numwal-nginx` in sync with these changes.
12-
13-
**PROTIP**: Triple-check your commits before you make them to watch for
14-
private key leaks!
11+
**PROTIP**: Triple-check your commits before you make them to watch
12+
for private key leaks!
1513

tls/keys/README-tls-keys.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Put public key certificate in this directory...

tls/private/README-tls-private.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Put private key in this directory...
2+
Please do this for self-signed test keys only.
3+
For a more secure setup, use a secure key server.

0 commit comments

Comments
 (0)