Redis Server
July 14, 2020 ยท View on GitHub
Before installing Redis, we recommend that you read through the security model of Redis, which is meant to be run within a strictly trusted environment. The below installation, and PANIC in general takes this security model into account and includes the suggested security boosts.
Installation
You can either install Redis directly on your system or use Docker. The former contains extra optional steps to reconfigure and secure Redis which are also useful if you choose the latter approach.
Installing Directly to System
-
To install Redis server on your system:
- On Linux, run:
sudo apt-get install redis-server # install Redis sudo systemctl enable redis-server.service # set Redis to start on boot - On Windows, follow the installation steps here
- On Linux, run:
-
To configure Redis:
-
First access the
redis.conffile:- On Linux:
sudo nano /etc/redis/redis.conf - On Windows: this is in the
conf/folder of the installation directory.
- On Linux:
-
In the
GENERALsection, add (or uncomment) the linebind 127.0.0.1to bind Redis only to localhost. This assumes that Redis is installed on the same system that will run the alerter. -
In the
SECURITYsection, add (or uncomment) the linerequirepass <PASS>, where<PASS>is a complex password of your choosing. The alerter will ask for this password during setup. -
In the
SECURITYsection, you can also choose to disable some commands to prevent some actions from taking place. For each command, add a line:rename-command <COMMAND> "".- The following commands are not used by PANIC and can thus be disabled:
FLUSHALL,PEXPIRE,CONFIG,SHUTDOWN,BGREWRITEAOF,BGSAVE,SAVE,SPOP,SREM,RENAMEandDEBUG. - You can disable them by copy pasting this code in the
SECURITYsection:
rename-command DEBUG "" rename-command RENAME "" rename-command SREM "" rename-command SPOP "" rename-command SAVE "" rename-command BGSAVE "" rename-command BGREWRITEAOF "" rename-command SHUTDOWN "" rename-command PEXPIRE "" rename-command FLUSHALL "" - The following commands are not used by PANIC and can thus be disabled:
-
On Linux, restart Redis to apply changes:
sudo service redis-server restart
-
-
To run Redis:
- On Linux, the Redis server should already be running.
- On Windows, run
redis-server.exefrom the installation directory as administrator with the config file as an argument:.\redis-server.exe conf\redis.conf
At the end, you should have:
- Redis server installed, secured, and running.
- Ability to use Redis via the
redis-clicommand.- On Windows,
redis-cli.exeis found in the installation directory. - To use Redis via the
redis-cli, remember to authenticate using your password:AUTH <PASSWORD>. - Note that you do not have to have the cli running for the alerter to work.
- On Windows,
Installing using Docker
To install and run Redis server on your system:
docker run -p 6379:6379 -d redis
To make sure that Redis is running:
docker ps
References and Further Reading:
- https://redis.io/topics/security
- https://redislabs.com/blog/3-critical-points-about-security/
- https://www.digitalocean.com/community/tutorials/how-to-encrypt-traffic-to-redis-with-spiped-on-ubuntu-16-04
- https://www.digitalocean.com/community/tutorials/how-to-secure-your-redis-installation-on-ubuntu-14-04
- https://www.digitalocean.com/community/tutorials/how-to-secure-your-redis-installation-on-ubuntu-18-04
- https://stackoverflow.com/questions/40114913/allow-redis-connections-from-only-localhost