From 73ff5c860d155d46ed65b6ae9caa9ee6e64478de Mon Sep 17 00:00:00 2001 From: algakzru Date: Tue, 10 Sep 2019 08:31:16 +0800 Subject: Set redis password (#856) --- 16.0/apache/config/redis.config.php | 1 + 16.0/apache/entrypoint.sh | 7 ++++++- 16.0/fpm-alpine/config/redis.config.php | 1 + 16.0/fpm-alpine/entrypoint.sh | 7 ++++++- 16.0/fpm/config/redis.config.php | 1 + 16.0/fpm/entrypoint.sh | 7 ++++++- 6 files changed, 21 insertions(+), 3 deletions(-) (limited to '16.0') diff --git a/16.0/apache/config/redis.config.php b/16.0/apache/config/redis.config.php index 5df799f2..19676160 100644 --- a/16.0/apache/config/redis.config.php +++ b/16.0/apache/config/redis.config.php @@ -6,6 +6,7 @@ if (getenv('REDIS_HOST')) { 'redis' => array( 'host' => getenv('REDIS_HOST'), 'port' => getenv('REDIS_HOST_PORT') ?: 6379, + 'password' => getenv('REDIS_HOST_PASSWORD'), ), ); } diff --git a/16.0/apache/entrypoint.sh b/16.0/apache/entrypoint.sh index 0be9d287..9514d881 100755 --- a/16.0/apache/entrypoint.sh +++ b/16.0/apache/entrypoint.sh @@ -25,7 +25,12 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP echo "Configuring Redis as session handler" { echo 'session.save_handler = redis' - echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}\"" + # check if redis password has been set + if [ -n "${REDIS_HOST_PASSWORD+x}" ]; then + echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\"" + else + echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}\"" + fi } > /usr/local/etc/php/conf.d/redis-session.ini fi diff --git a/16.0/fpm-alpine/config/redis.config.php b/16.0/fpm-alpine/config/redis.config.php index 5df799f2..19676160 100644 --- a/16.0/fpm-alpine/config/redis.config.php +++ b/16.0/fpm-alpine/config/redis.config.php @@ -6,6 +6,7 @@ if (getenv('REDIS_HOST')) { 'redis' => array( 'host' => getenv('REDIS_HOST'), 'port' => getenv('REDIS_HOST_PORT') ?: 6379, + 'password' => getenv('REDIS_HOST_PASSWORD'), ), ); } diff --git a/16.0/fpm-alpine/entrypoint.sh b/16.0/fpm-alpine/entrypoint.sh index 0be9d287..9514d881 100755 --- a/16.0/fpm-alpine/entrypoint.sh +++ b/16.0/fpm-alpine/entrypoint.sh @@ -25,7 +25,12 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP echo "Configuring Redis as session handler" { echo 'session.save_handler = redis' - echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}\"" + # check if redis password has been set + if [ -n "${REDIS_HOST_PASSWORD+x}" ]; then + echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\"" + else + echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}\"" + fi } > /usr/local/etc/php/conf.d/redis-session.ini fi diff --git a/16.0/fpm/config/redis.config.php b/16.0/fpm/config/redis.config.php index 5df799f2..19676160 100644 --- a/16.0/fpm/config/redis.config.php +++ b/16.0/fpm/config/redis.config.php @@ -6,6 +6,7 @@ if (getenv('REDIS_HOST')) { 'redis' => array( 'host' => getenv('REDIS_HOST'), 'port' => getenv('REDIS_HOST_PORT') ?: 6379, + 'password' => getenv('REDIS_HOST_PASSWORD'), ), ); } diff --git a/16.0/fpm/entrypoint.sh b/16.0/fpm/entrypoint.sh index 0be9d287..9514d881 100755 --- a/16.0/fpm/entrypoint.sh +++ b/16.0/fpm/entrypoint.sh @@ -25,7 +25,12 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP echo "Configuring Redis as session handler" { echo 'session.save_handler = redis' - echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}\"" + # check if redis password has been set + if [ -n "${REDIS_HOST_PASSWORD+x}" ]; then + echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\"" + else + echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}\"" + fi } > /usr/local/etc/php/conf.d/redis-session.ini fi -- cgit v1.2.3