From 6d9113c277d85aa92b40771d55bbc2ece1977d17 Mon Sep 17 00:00:00 2001 From: Fred Date: Sun, 2 Feb 2020 11:20:55 -0500 Subject: [PATCH 1/3] Add support for client parameter, file cleanup --- DOCK1 | 1 - Dockerfile | 1 + README.md | 6 ++++++ generateconfig.sh | 15 +++++++++++++++ start.sh | 2 +- stunnel.conf | 6 ------ test/dockerfile | 3 --- test/index.js | 1 - 8 files changed, 23 insertions(+), 12 deletions(-) delete mode 100644 DOCK1 create mode 100644 generateconfig.sh delete mode 100644 stunnel.conf delete mode 100644 test/dockerfile delete mode 100644 test/index.js diff --git a/DOCK1 b/DOCK1 deleted file mode 100644 index c394738..0000000 --- a/DOCK1 +++ /dev/null @@ -1 +0,0 @@ -FROM node diff --git a/Dockerfile b/Dockerfile index 8420c44..796c614 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,7 @@ RUN apt-get update && apt-get install -y stunnel4 VOLUME /stunnel ADD ./stunnel.conf /stunnel/ +ADD ./generateconfig.sh / ADD ./start.sh / CMD [ "/start.sh" ] diff --git a/README.md b/README.md index 7ab3573..7875a4c 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,12 @@ docker run -d \ runnable/redis-stunnel ``` +## Environment variables +Use the following env variables to modify your stunnel configuration : +REDIS_PORT_6379_TCP_ADDR : hostname of Redis server endpoint +REDIS_PORT_6379_TCP_PORT : port of Redis server endpoint +REDIS_STUNNEL_CLIENT_MODE : [yes|no] client vs server mode + ## Testing the Setup To test the `stunnel` setup, run the following NodeJS script. It should print out `[]` (an empty list) if it is a clean Redis server, but would otherwise print out all the keys on the server. diff --git a/generateconfig.sh b/generateconfig.sh new file mode 100644 index 0000000..2f31227 --- /dev/null +++ b/generateconfig.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +clientMode="${REDIS_STUNNEL_CLIENT_MODE:-no}" + +#define the template config. +cat << EOF +cert = /stunnel/private.pem +pid = /var/run/stunnel.pid +foreground = yes +[redis] +accept = 0.0.0.0:6380 +; connect and client config are added by start.sh +client = $clientMode +connect = $REDIS_PORT_6379_TCP_ADDR:$REDIS_PORT_6379_TCP_PORT +EOF diff --git a/start.sh b/start.sh index 4da84d6..409c04c 100755 --- a/start.sh +++ b/start.sh @@ -1,4 +1,4 @@ #!/bin/sh -echo "connect = $REDIS_PORT_6379_TCP_ADDR:$REDIS_PORT_6379_TCP_PORT" >> /stunnel/stunnel.conf +./generateconfig.sh > /stunnel/stunnel.conf stunnel4 /stunnel/stunnel.conf diff --git a/stunnel.conf b/stunnel.conf deleted file mode 100644 index 077a190..0000000 --- a/stunnel.conf +++ /dev/null @@ -1,6 +0,0 @@ -cert = /stunnel/private.pem -pid = /var/run/stunnel.pid -foreground = yes -[redis] -accept = 0.0.0.0:6380 -; connect is added by start.sh diff --git a/test/dockerfile b/test/dockerfile deleted file mode 100644 index f50afd2..0000000 --- a/test/dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -from ruby -ADD ./index.js /index.js -CMD sleep 1000 diff --git a/test/index.js b/test/index.js deleted file mode 100644 index 45b983b..0000000 --- a/test/index.js +++ /dev/null @@ -1 +0,0 @@ -hi From 80a2db7e974efa9fdfc092acad5286fb409ad391 Mon Sep 17 00:00:00 2001 From: frebou Date: Sun, 2 Feb 2020 11:45:49 -0500 Subject: [PATCH 2/3] Update README.md correction to format --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7875a4c..6a38507 100644 --- a/README.md +++ b/README.md @@ -53,11 +53,12 @@ docker run -d \ runnable/redis-stunnel ``` -## Environment variables +### Environment variables Use the following env variables to modify your stunnel configuration : -REDIS_PORT_6379_TCP_ADDR : hostname of Redis server endpoint -REDIS_PORT_6379_TCP_PORT : port of Redis server endpoint -REDIS_STUNNEL_CLIENT_MODE : [yes|no] client vs server mode + +- REDIS_PORT_6379_TCP_ADDR : hostname of Redis server endpoint +- REDIS_PORT_6379_TCP_PORT : port of Redis server endpoint +- REDIS_STUNNEL_CLIENT_MODE : [yes|no] client vs server mode ## Testing the Setup From aa0486fd953898a847f34d8c9420972c80d220f7 Mon Sep 17 00:00:00 2001 From: Fred Date: Sun, 2 Feb 2020 12:10:18 -0500 Subject: [PATCH 3/3] fix to dockerfile for missing file --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 796c614..a316ee5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,6 @@ EXPOSE 6380 RUN apt-get update && apt-get install -y stunnel4 VOLUME /stunnel -ADD ./stunnel.conf /stunnel/ ADD ./generateconfig.sh / ADD ./start.sh /