From 29b115a03cbad3d9e18083af223f62b44e268ed0 Mon Sep 17 00:00:00 2001 From: "Simon L." Date: Fri, 9 Jan 2026 15:18:43 +0100 Subject: [PATCH] redis.config.php: allow to configure redis.cluster Signed-off-by: Simon L. --- Containers/nextcloud/Dockerfile | 4 +-- Containers/nextcloud/config/redis.config.php | 30 ++++++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Containers/nextcloud/Dockerfile b/Containers/nextcloud/Dockerfile index 6b6be7f8..f3c989f1 100644 --- a/Containers/nextcloud/Dockerfile +++ b/Containers/nextcloud/Dockerfile @@ -138,8 +138,8 @@ RUN set -ex; \ } > /usr/local/etc/php/conf.d/nextcloud.ini; \ \ { \ - echo 'session.save_handler = redis'; \ - echo 'session.save_path = "tcp://${REDIS_HOST}:${REDIS_PORT}?database=${REDIS_DB_INDEX}${REDIS_USER_AUTH}&auth[]=${REDIS_HOST_PASSWORD}"'; \ + echo 'session.save_handler = rediscluster'; \ + echo 'session.save_path = "seed[]=${REDIS_HOST}:${REDIS_PORT}&seed[]=${REDIS_HOST_2}:${REDIS_PORT_2}&seed[]=${REDIS_HOST_3}:${REDIS_PORT_3}&seed[]=${REDIS_HOST_4}:${REDIS_PORT_4}&seed[]=${REDIS_HOST_5}:${REDIS_PORT_5}&seed[]=${REDIS_HOST_6}:${REDIS_PORT_6}&seed[]=${REDIS_HOST_7}:${REDIS_PORT_7}&seed[]=${REDIS_HOST_8}:${REDIS_PORT_8}&seed[]=${REDIS_HOST_9}:${REDIS_PORT_9}&timeout=0&read_timeout=0&failover=error&persistent=1&auth=${REDIS_HOST_PASSWORD}&stream[verify_peer]=0"'; \ echo 'redis.session.locking_enabled = 1'; \ echo 'redis.session.lock_retries = -1'; \ echo 'redis.session.lock_wait_time = 10000'; \ diff --git a/Containers/nextcloud/config/redis.config.php b/Containers/nextcloud/config/redis.config.php index b59fe4ea..1d0ee369 100644 --- a/Containers/nextcloud/config/redis.config.php +++ b/Containers/nextcloud/config/redis.config.php @@ -1,5 +1,5 @@ '\OC\Memcache\Redis', 'memcache.locking' => '\OC\Memcache\Redis', @@ -17,7 +17,33 @@ if (getenv('REDIS_HOST')) { $CONFIG['redis']['dbindex'] = (int) getenv('REDIS_DB_INDEX'); } - if (getenv('REDIS_USER_AUTH') !== false) { + if (getenv('REDIS_USER_AUTH')) { $CONFIG['redis']['user'] = str_replace("&auth[]=", "", getenv('REDIS_USER_AUTH')); } +} else { + $CONFIG = array( + 'memcache.distributed' => '\OC\Memcache\Redis', + 'memcache.locking' => '\OC\Memcache\Redis', + 'redis.cluster' => array( + 'password' => (string) getenv('REDIS_HOST_PASSWORD'), + 'timeout' => 0.0, + 'read_timeout' => 0.0, + 'failover_mode' => \RedisCluster::FAILOVER_ERROR, + 'seeds' => array( + getenv('REDIS_HOST') . ':' . (string)getenv('REDIS_PORT'), + getenv('REDIS_HOST_2') . ':' . (string)getenv('REDIS_PORT_2'), + getenv('REDIS_HOST_3') . ':' . (string)getenv('REDIS_PORT_3'), + getenv('REDIS_HOST_4') . ':' . (string)getenv('REDIS_PORT_4'), + getenv('REDIS_HOST_5') . ':' . (string)getenv('REDIS_PORT_5'), + getenv('REDIS_HOST_6') . ':' . (string)getenv('REDIS_PORT_6'), + getenv('REDIS_HOST_7') . ':' . (string)getenv('REDIS_PORT_7'), + getenv('REDIS_HOST_8') . ':' . (string)getenv('REDIS_PORT_8'), + getenv('REDIS_HOST_9') . ':' . (string)getenv('REDIS_PORT_9'), + ), + ), + ); + + if (getenv('REDIS_USER_AUTH')) { + $CONFIG['redis.cluster']['user'] = str_replace("&auth[]=", "", getenv('REDIS_USER_AUTH')); + } }