Skip to content

Commit cc62ed6

Browse files
committed
feat: Add support for Redis host TLS
Signed-off-by: Simon Guyennet <simon.guyennet@corp.ovh.com>
1 parent 0af85f2 commit cc62ed6

6 files changed

Lines changed: 72 additions & 18 deletions

File tree

31/apache/entrypoint.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,19 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
131131
fi
132132
# check if redis password has been set
133133
elif [ -n "${REDIS_HOST_PASSWORD+x}" ]; then
134-
if [ -n "${REDIS_HOST_USER+x}" ]; then
135-
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\""
134+
# check if redis host is using tls
135+
if [ "$(echo "$REDIS_HOST" | cut -c1-6)" = "tls://" ]; then
136+
if [ -n "${REDIS_HOST_USER+x}" ]; then
137+
echo "session.save_path = \"${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\""
138+
else
139+
echo "session.save_path = \"${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\""
140+
fi
136141
else
137-
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\""
142+
if [ -n "${REDIS_HOST_USER+x}" ]; then
143+
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\""
144+
else
145+
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\""
146+
fi
138147
fi
139148
else
140149
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}\""

31/fpm-alpine/entrypoint.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,19 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
131131
fi
132132
# check if redis password has been set
133133
elif [ -n "${REDIS_HOST_PASSWORD+x}" ]; then
134-
if [ -n "${REDIS_HOST_USER+x}" ]; then
135-
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\""
134+
# check if redis host is using tls
135+
if [ "$(echo "$REDIS_HOST" | cut -c1-6)" = "tls://" ]; then
136+
if [ -n "${REDIS_HOST_USER+x}" ]; then
137+
echo "session.save_path = \"${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\""
138+
else
139+
echo "session.save_path = \"${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\""
140+
fi
136141
else
137-
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\""
142+
if [ -n "${REDIS_HOST_USER+x}" ]; then
143+
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\""
144+
else
145+
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\""
146+
fi
138147
fi
139148
else
140149
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}\""

31/fpm/entrypoint.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,19 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
131131
fi
132132
# check if redis password has been set
133133
elif [ -n "${REDIS_HOST_PASSWORD+x}" ]; then
134-
if [ -n "${REDIS_HOST_USER+x}" ]; then
135-
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\""
134+
# check if redis host is using tls
135+
if [ "$(echo "$REDIS_HOST" | cut -c1-6)" = "tls://" ]; then
136+
if [ -n "${REDIS_HOST_USER+x}" ]; then
137+
echo "session.save_path = \"${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\""
138+
else
139+
echo "session.save_path = \"${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\""
140+
fi
136141
else
137-
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\""
142+
if [ -n "${REDIS_HOST_USER+x}" ]; then
143+
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\""
144+
else
145+
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\""
146+
fi
138147
fi
139148
else
140149
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}\""

32/apache/entrypoint.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,19 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
131131
fi
132132
# check if redis password has been set
133133
elif [ -n "${REDIS_HOST_PASSWORD+x}" ]; then
134-
if [ -n "${REDIS_HOST_USER+x}" ]; then
135-
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\""
134+
# check if redis host is using tls
135+
if [ "$(echo "$REDIS_HOST" | cut -c1-6)" = "tls://" ]; then
136+
if [ -n "${REDIS_HOST_USER+x}" ]; then
137+
echo "session.save_path = \"${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\""
138+
else
139+
echo "session.save_path = \"${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\""
140+
fi
136141
else
137-
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\""
142+
if [ -n "${REDIS_HOST_USER+x}" ]; then
143+
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\""
144+
else
145+
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\""
146+
fi
138147
fi
139148
else
140149
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}\""

32/fpm-alpine/entrypoint.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,19 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
131131
fi
132132
# check if redis password has been set
133133
elif [ -n "${REDIS_HOST_PASSWORD+x}" ]; then
134-
if [ -n "${REDIS_HOST_USER+x}" ]; then
135-
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\""
134+
# check if redis host is using tls
135+
if [ "$(echo "$REDIS_HOST" | cut -c1-6)" = "tls://" ]; then
136+
if [ -n "${REDIS_HOST_USER+x}" ]; then
137+
echo "session.save_path = \"${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\""
138+
else
139+
echo "session.save_path = \"${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\""
140+
fi
136141
else
137-
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\""
142+
if [ -n "${REDIS_HOST_USER+x}" ]; then
143+
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\""
144+
else
145+
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\""
146+
fi
138147
fi
139148
else
140149
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}\""

32/fpm/entrypoint.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,19 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
131131
fi
132132
# check if redis password has been set
133133
elif [ -n "${REDIS_HOST_PASSWORD+x}" ]; then
134-
if [ -n "${REDIS_HOST_USER+x}" ]; then
135-
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\""
134+
# check if redis host is using tls
135+
if [ "$(echo "$REDIS_HOST" | cut -c1-6)" = "tls://" ]; then
136+
if [ -n "${REDIS_HOST_USER+x}" ]; then
137+
echo "session.save_path = \"${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\""
138+
else
139+
echo "session.save_path = \"${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\""
140+
fi
136141
else
137-
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\""
142+
if [ -n "${REDIS_HOST_USER+x}" ]; then
143+
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\""
144+
else
145+
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\""
146+
fi
138147
fi
139148
else
140149
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}\""

0 commit comments

Comments
 (0)