Redis not talking to Apache jail

Hello all,

Hope someone can help me solve my problem. I have two jails (ezjail) on a FreeBSD 11.1 host (UFS): one running Apache 2.4 (192.168.0.2) and the other one running MariaDB 10.2 (192.168.0.3). The Apache jail has PHP 7.2 and Nextcloud 12. Nextcloud is running fine. No problems there.
However, the Nextcloud project and some other websites suggest running a caching service for optimum performance e.g. Nextcloud: Configuring Memory Caching

I have installed Redis in the MariaDB jail, but it needs to talk the Apache jail.

I hae added the following to the nextcloud config file (/usr/local/www/apache24/data/nextcloud/config/config.php) ?
Code:
'memcache.local' => '\\OC\\Memcache\\Redis',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'redis' => array(
  'host' => '192.168.0.2',
  'port' => 6379,
),
Redis is running and added to rc.conf in the MariaDB jail.

When entering redis-cli

Code:
root@mariadbserver:~ # redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused

If i understand things correctly there's no such thing as a 127.0.0.1 local loopback between jails.

When I add these lines, the Nextcloud website stops working. There are no issues in /var/log/httpd-error.log wrt Nextcloud?

My question is how can I fix this and get redis to connect to the apache jail?

Thank you so much in advance.
 
Actually there is loopback between jails, and it is recommended to create a separated one from the host:

/etc/rc.conf
Code:
cloned_interfaces="lo1"

And then set the jails to use that instead of lo.

You may also need to set firewall to allow that. If you are using pf(1) you need something like this to allow the traffic between them:

Code:
set skip on lo1

I had www/nextcloud running right fine in a very similar configuration without problem.

I do not have databases/redis installed anymore and I do not remember the details, but you should point redis-cli to the address databases/redis is configure to listen to.

EDIT: BTW, databases/redis recommends that just what actually needs to access it should be allowed to.
 
So, I had another go at updating the redis config files. Yes, I have PF set up and running the loopback on lo1. I've added the jail's IP (192.168.0.3) and the port to the configuration:

ee /usr/local/etc/redis.conf

Code:
# By default, if no "bind" configuration directive is specified, Redis listens
# for connections from all the network interfaces available on the server.
# It is possible to listen to just one or multiple selected interfaces using
# the "bind" configuration directive, followed by one or more IP addresses.

bind 192.168.0.3
port 6379

No errors in the log file:
ee /var/log/redis.conf
Code:
1813:M 17 Nov 22:56:23.177 # Server started, Redis version 3.2.10
1813:M 17 Nov 22:56:23.177 * DB loaded from disk: 0.000 seconds
1813:M 17 Nov 22:56:23.178 * The server is now ready to accept connections on port 6379

however when I enter
redis-cli
Code:
127.0.0.1:6379>

Why is the 127.0.0.1 not changing to 192.168.0.3?

i must be missing something somewhere.
 
Thanks for the suggestions. I left it for a couple weeks, and tried again. Got it working now. Yeah.
I changed things slightly, and also put Redis in its own jail. Now all's working with 3 jails (web server, database, redis).
Will post a howto soon.
 
Back
Top