Nextcloud with redis

Isma

Contributor
Joined
Apr 29, 2020
Messages
100
Hi, I'm trying to add redis to my nextcloud instance.
I install the redis app and assign it, for example, port 30036 and password 123

I go to the nextcloud instance and set the variables
Name REDIS_HOST
Value 127.0.0.1

REDIS_HOST_PORT
Value 30036

REDIS_HOST_PASSWORD
Value 123

I configure the config in nextcloud adding as they say in their sampleconfig

'redis' => [
'host' => 'localhost', // can also be a unix domain socket: '/tmp/redis.sock'
'port' => 30036,
'timeout' => 0.0,
'read_timeout' => 0.0,
'user' => '', // Optional: if not defined, no password will be used.
'password' => '123', // Optional: if not defined, no password will be used.
'dbindex' => 0, // Optional: if undefined SELECT will not run and will use Redis Server's default DB Index.
],


Also modify the port in the redis.config.php file

<?php
if (getenv('REDIS_HOST')) {
$CONFIG = array(
'memcache.distributed' => '\OC\Memcache\Redis',
'memcache.locking' => '\OC\Memcache\Redis',
'redis' => array(
'host' => getenv('REDIS_HOST'),
'password' => (string) getenv('REDIS_HOST_PASSWORD'),
),
);

if (getenv('REDIS_HOST_PORT') !== false) {
$CONFIG['redis']['port'] = (int) getenv('REDIS_HOST_PORT');
} elseif (getenv('REDIS_HOST')[0] != '/') {
$CONFIG['redis']['port'] = 30036;
}
}

should I change ???
'memcache.local' => '\\OC\\Memcache\\APCu'

The most I got was that the login loaded but I went into a loop when logging in, I returned to the login page and I can never access

<?php
$CONFIG = array (
'htaccess.RewriteBase' => '/',
'memcache.local' => '\\OC\\Memcache\\APCu',
'apps_paths' =>
array (
0 =>
array (
'path' => '/var/www/html/apps',
'url' => '/apps',
'writable' => false,
),
1 =>
array (
'path' => '/var/www/html/custom_apps',
'url' => '/custom_apps',
'writable' => true,
),
),
'passwordsalt' => '/6O*****i8',
'secret' => 'U*******T',
'trusted_domains' =>
array (
0 => '*********.com',
1 => '192.168.1.100',
),


'trusted_proxies' =>
array (
0 => '10.42.0.0/16',
1 => '103.21.244.0/22',
2 => '103.22.200.0/22',
3 => '103.31.4.0/22',
4 => '104.16.0.0/12',
5 => '108.162.192.0/18',
6 => '131.0.72.0/22',
7 => '141.101.64.0/18',
8 => '162.158.0.0/15',
9 => '172.64.0.0/13',
10 => '173.245.48.0/20',
11 => '188.114.96.0/20',
12 => '190.93.240.0/20',
13 => '197.234.240.0/22',
14 => '198.41.128.0/17',
15 => '2400:cb00::/32',
16 => '2606:4700::/32',
17 => '2803:f800::/32',
18 => '2405:b500::/32',
19 => '2405:8100::/32',
20 => '2c0f:f248::/32',

),
'forwarded_for_headers' =>
array (
0 => 'HTTP_CF_CONNECTING_IP',
),


'default_language' => 'es',
'force_language' => 'es',
'default_locale' => 'es_ES',
'default_phone_region' => 'ES',

'datadirectory' => '/var/www/html/data',
'dbtype' => 'pgsql',
'version' => '27.1.3.2',
'overwrite.cli.url' => 'http://localhost',
'dbname' => 'nextcloud',
'dbhost' => 'nextcloud-postgres:5432',
'dbport' => '',
'dbtableprefix' => 'oc_',
'dbuser' => 'oc_admin',
'dbpassword' => 'UB6ko******m',
'installed' => true,
'instanceid' => 'oc******t',


'redis' => [
'host' => 'localhost', // can also be a unix domain socket: '/tmp/redis.sock'
'port' => 30036,
'timeout' => 0.0,
'read_timeout' => 0.0,
'user' => '', // Optional: if not defined, no password will be used.
'password' => '123', // Optional: if not defined, no password will be used.
'dbindex' => 0, // Optional: if undefined SELECT will not run and will use Redis Server's default DB Index.
],



);
 

Isma

Contributor
Joined
Apr 29, 2020
Messages
100
If you want to use Redis you have to create a separate Redis container in your setup / in your docker-compose file. To inform Nextcloud about the Redis container, pass in the following parameters:

  • 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_PASSWORD (not set by default) Redis password
The use of Redis is recommended to prevent file locking problems. See the examples for further instructions.
 

LarsR

Guru
Joined
Oct 23, 2020
Messages
719
The truecharts version installs redis as a side container by default for anyone who doesn't want to run a separate redis container.
 

Isma

Contributor
Joined
Apr 29, 2020
Messages
100
The truecharts version installs redis as a side container by default for anyone who doesn't want to run a separate redis container.
I see the configuration, but how do I activate it?
 

Isma

Contributor
Joined
Apr 29, 2020
Messages
100
Maybe?


'memcache.local' => '\\OC\\Memcache\\APCu',

'memcache.distributed' => '\OC\Memcache\Redis',

'memcache.locking' => '\OC\Memcache\Redis',

'redis' => array(

'host' => 'localhost',

),
 

LarsR

Guru
Joined
Oct 23, 2020
Messages
719
as far as i know its activated by default - no further configuration required.
 

Isma

Contributor
Joined
Apr 29, 2020
Messages
100
as far as i know its activated by default - no further configuration required.
I have this notice

The database is used for transactional file locking. To improve performance, please configure memcache, if available. See the documentation ↗ for more information.
 

Isma

Contributor
Joined
Apr 29, 2020
Messages
100
correct!!
just add this to your config.php and it will activate

'filelocking.enabled' => true,
'memcache.locking' => '\OC\Memcache\Redis',
'redis' => array(
'host' => 'localhost',
'port' => 6379,
'timeout' => 0.0,
'password' => '', // Optional, if not defined no password will be used.
),
 

Isma

Contributor
Joined
Apr 29, 2020
Messages
100
as far as i know its activated by default - no further configuration required.
but although it worked, I lost access to the external storages, they were inaccessible and although they appeared added with the green tick, they are not shown in the file explorer, when I returned to the default format everything worked again, so it was of no use
 
Top