How To Use the Redis One-Click Application
Redis is a scalable in-memory key-value store that excels at caching. DigitalOcean's Redis One-Click application allows you to quickly spin up a Droplet with Redis pre-installed. It aims to help get your application off the ground quickly.
Creating Your Redis Droplet
You can launch a new Redis instance by selecting Redis on 14.04 from the Applications menu during Droplet creation:
Once you have created the Droplet, connect to it via the web-based console in the DigitalOcean control panel or SSH:
Your Redis instance will be available at
127.0.0.1:6379 It is bound to the localhost by default and its configuration details can be found in
/etc/redis/redis.conf. To connect to Redis's interactive shell, simply run:
Securing And Accessing Remotely
Before allowing remote access to your Redis database, it is recommended to enable password authentication. To do so, open its configuration file located in
/etc/redis/redis.conf and append a line beginning with "requirepass" and followed by your password. For example:
In order for this to take effect, you must first restart Redis with:
- sudo service redis restart
To verify that authentication has been enabled, enter the shell with
redis-cli and attempt to run a query. You should be presented with an error:
- CONFIG GET databases
- (error) NOAUTH Authentication required.
To provide the password you set, run:
- AUTH your_redis_password
Your can also provide you password directly on the command line when starting the redis client:
- redis-cli -a your_redis_password"
Enabling Remote Access
In order to enable access over the internet, comment out the line beginning with
/etc/redis/redis.conf. Find this:
and change it to this:
# bind 127.0.0.1
Then restart Redis to enable the change.
- sudo service redis restart
Now you can connect to your Redis instance from a remote host using the command:
- redis-cli -h redis_ip_address -p 6379 -a your_redis_password
Additional Security Steps
In addition to enabling authentication, setting up a firewall that only allows remote connections from specific IP addresses is a good security measure to implement. Managing an IP Tables firewall is made easy using UFW on Ubuntu. The following commands will erect a firewall which allows all outgoing connections from your server but only allow incoming connections via SSH or from the specified IP address (ip.address.to.allow).
- sudo apt-get install ufw
- sudo ufw default deny incoming
- sudo ufw default allow outgoing
- sudo ufw allow ssh
- sudo ufw allow from ip.address.to.allow
- sudo ufw enable
For additional security recommendations, see Redis's security docs.
The One-Click application simply provides you with Redis as a pre-installed base. It's up to you how you want to use it. Whether you are building out a cluster or you simply want to use it as a local cache for an app on the same host, we have a number of tutorials which should point you in the right direction: