Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .config/redis.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
'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;
}

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading