top of page

Solar ECG Private Li Group

Public·314 members

Install and Configure Redis Server on Ubuntu 24.04 Securely

Redis is an open-source, in-memory key-value data store widely used for caching, real-time analytics, messaging queues, and session management. Its high performance and flexibility make it a go-to solution for developers and system administrators seeking fast and efficient data access. In this blog, we’ll walk through how to install Redis and configure it securely on Ubuntu 24.04, using the official step-by-step guide from Vultr.

Why Secure Redis?

By default, Redis does not enable authentication or restrict access, which can be dangerous if your server is exposed to the internet. Misconfigured Redis instances are common attack vectors, leading to data breaches, malware injection, and unauthorized control of systems. Therefore, secure configuration is critical in production environments.

Step 1: Update Your System

Before you install Redis, update your system’s package index and upgrade the existing packages:

sudo apt update && sudo apt upgrade -y


This ensures all dependencies are current and avoids conflicts during installation.

Step 2: Install Redis

Use the following command to install Redis from Ubuntu’s default repositories:

sudo apt install redis-server -y


The Redis service and its dependencies will be downloaded and installed automatically.

Step 3: Configure Redis for Systemd Supervision

After installation, configure Redis to run under systemd, which helps manage the service more efficiently:

sudo nano /etc/redis/redis.conf


Find the line:

supervised no


Change it to:

supervised systemd


Save and exit the file (Ctrl+O, Enter, then Ctrl+X).

Then restart Redis to apply the changes:

sudo systemctl restart redis


Step 4: Enable Redis to Start on Boot

Ensure Redis starts automatically when your server reboots:

sudo systemctl enable redis


Step 5: Verify Redis is Running

To confirm that Redis is active and running:

sudo systemctl status redis


You should see output indicating that the Redis service is active.

You can also test Redis directly using the command-line interface:

redis-cli


Then enter:

ping


If Redis is working properly, it will return:

PONG


Step 6: Secure Redis Configuration

Now that Redis is installed, it’s time to make it secure.

1. Bind Redis to Localhost Only

Open the configuration file again:

sudo nano /etc/redis/redis.conf


Ensure the following line is set to restrict access:

bind 127.0.0.1


This ensures Redis only accepts local connections.

2. Set a Password

Still in the redis.conf file, find and uncomment the requirepass directive:

requirepass YourStrongPasswordHere


This enforces authentication, preventing unauthorized access.

3. Disable Dangerous Commands

To reduce risk, disable certain commands like FLUSHALL and CONFIG:

rename-command CONFIG ""

rename-command FLUSHALL ""

rename-command FLUSHDB ""


This makes it harder for attackers to exploit your Redis instance.

4. Configure a Firewall

Use UFW (Uncomplicated Firewall) to block external access to Redis:

sudo ufw allow OpenSSH

sudo ufw enable

sudo ufw deny 6379


This ensures Redis can only be accessed locally.

Step 7: Restart and Test

After making all changes, restart Redis:

sudo systemctl restart redis


Then, connect using the Redis CLI and authenticate:

redis-cli


When prompted, enter:

auth YourStrongPasswordHere


A successful response will be:

OK


Conclusion

Installing and configuring Redis on Ubuntu 24.04 is straightforward, but securing it properly is just as important. By following this tutorial and using the trusted guide from Vultr , you can deploy a robust, high-performance Redis server with essential security best practices in place. Whether you're using Redis for caching, queues, or real-time data processing, a secure setup ensures your applications remain fast and protected.


2 Views

Subscribe Form

Thanks for submitting!

+91-8700932892

  • Facebook
  • Twitter
  • LinkedIn
  • Whatsapp

©2023 by Solar ECG Private Limited All Rights Reserved

bottom of page