Linux – Server closed connection error when checking if key exists in a redis cluster using stunnel

linuxredisstunnel

Using redis-cli command line utility with the -c switch to connect to a redis cluster with stunnel configured and running.

When I execute the EXISTS command to verify a key, as expected, it redirects to the node that contains the key however, get the following error:

127.0.0.1:7000> EXISTS foo
-> Redirected to slot [12182] located at 127.0.0.1:7002
Error: Server closed the connection

When I don't use stunnel it works just fine returning the expected output. However, I want to ensure the connection from the client is encrypted.

Is something needed in the config file stunnel.conf such as the nodes' IP addresses and/or ports? What are recommended steps to configure redis-cli connecting to a cluster with stunnel?

Best Answer

You will need to configure one stunnel connection for each port that your cluster uses. Then, when your client is redirected to 127.0.0.1:7002, it will be able to connect via the stunnel connection for that port.