diff --git a/.config/redis.config.php b/.config/redis.config.php index 2069812f..415339d3 100644 --- a/.config/redis.config.php +++ b/.config/redis.config.php @@ -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; } diff --git a/README.md b/README.md index 8188dcb2..b4ad5fca 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 4fc363f3..8c1a1f25 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -108,7 +108,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