Refactor Redis connection for TLS and unix sockets (#2557)

Signed-off-by: J0WI <J0WI@users.noreply.github.com>
pull/2604/head
J0WI 1 month ago committed by GitHub
parent 6edd06e234
commit 580999b9c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -4,14 +4,16 @@ if (getenv('REDIS_HOST')) {
'memcache.distributed' => '\OC\Memcache\Redis',
'memcache.locking' => '\OC\Memcache\Redis',
'redis' => array(
'host' => getenv('REDIS_HOST'),
'host' => (getenv('REDIS_HOST')[0] === '/' ? 'unix' : (getenv('REDIS_PROTOCOL') ?: 'tcp')) . "://" . getenv('REDIS_HOST'),
'password' => getenv('REDIS_HOST_PASSWORD_FILE') ? trim(file_get_contents(getenv('REDIS_HOST_PASSWORD_FILE'))) : (string) getenv('REDIS_HOST_PASSWORD'),
),
);
if (getenv('REDIS_HOST_PORT') !== false) {
if (getenv('REDIS_HOST')[0] === '/') {
$CONFIG['redis']['port'] = 0;
} elseif (getenv('REDIS_HOST_PORT') !== false) {
$CONFIG['redis']['port'] = (int) getenv('REDIS_HOST_PORT');
} elseif (getenv('REDIS_HOST')[0] != '/') {
} else {
$CONFIG['redis']['port'] = 6379;
}

@ -285,10 +285,11 @@ You might want to make sure the htaccess is up to date after each container upda
To use Redis for memory caching as well as PHP session storage, specify the following values and also add a [Redis](https://hub.docker.com/_/redis/) container to your stack. See the [examples](https://github.com/nextcloud/docker/tree/master/.examples) for further instructions.
- `REDIS_HOST` (not set by default) Name of Redis container
- `REDIS_HOST` (not set by default) Name of Redis container.
- `REDIS_HOST_PORT` (default: `6379`) Optional port for Redis, only use for external Redis servers that run on non-standard ports.
- `REDIS_HOST_USER` (not set by default) Optional username for Redis, only use for external Redis servers that require a user.
- `REDIS_HOST_PASSWORD` (not set by default) Redis password
- `REDIS_HOST_PASSWORD` (not set by default) Redis password.
- `REDIS_PROTOCOL` (default: `tcp`) Set to `tls` to use TLS when connecting to Redis server.
Check the [Nextcloud documentation](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/caching_configuration.html) for more information.

@ -107,7 +107,7 @@ configure_redis_session() {
redis_save_path="unix://${REDIS_HOST}"
;;
*)
redis_save_path="tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}"
redis_save_path="${REDIS_PROTOCOL:=tcp}://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}"
;;
esac

Loading…
Cancel
Save