📖 Scenario: You are setting up a Redis server on your local machine for development. Redis has a security feature called Protected Mode that helps prevent unauthorized access when Redis is exposed to the network.In this project, you will learn how to check and configure Redis Protected Mode settings to keep your server safe.
🎯 Goal: Configure Redis to enable or disable Protected Mode by editing the Redis configuration file and verifying the setting.
📋 What You'll Learn
Create a Redis configuration file with Protected Mode enabled
Add a configuration line to disable Protected Mode
Write a command to check the current Protected Mode status
Add a final configuration line to re-enable Protected Mode
💡 Why This Matters
🌍 Real World
Redis Protected Mode helps protect your Redis server from unauthorized access when running on public or shared networks.
💼 Career
Understanding Redis security settings like Protected Mode is essential for database administrators and backend developers to keep data safe.
Progress0 / 4 steps
1
Create Redis configuration with Protected Mode enabled
Create a Redis configuration file named redis.conf with the line protected-mode yes to enable Protected Mode.
Redis
Hint
Protected Mode is enabled by default with the line protected-mode yes.
2
Disable Protected Mode in the configuration
Add a line protected-mode no to the redis.conf file to disable Protected Mode.
Redis
Hint
Disabling Protected Mode is done by setting protected-mode no.
3
Check the current Protected Mode status using Redis CLI
Write the Redis CLI command CONFIG GET protected-mode to check the current Protected Mode status.
Redis
Hint
Use CONFIG GET protected-mode in Redis CLI to see if Protected Mode is enabled or disabled.
4
Re-enable Protected Mode in the configuration
Add the line protected-mode yes again at the end of redis.conf to re-enable Protected Mode.
Redis
Hint
To re-enable Protected Mode, add protected-mode yes at the end of the configuration file.
Practice
(1/5)
1. What is the main purpose of Redis protected-mode?
easy
A. To increase Redis performance by caching data
B. To limit connections and keep Redis safe by default
C. To enable automatic backups of Redis data
D. To allow unlimited remote connections without restrictions
Solution
Step 1: Understand what protected mode does
Protected mode is designed to keep Redis safe by limiting who can connect to it.
Step 2: Identify the main purpose
It prevents unauthorized access by restricting connections unless properly configured.
Final Answer:
To limit connections and keep Redis safe by default -> Option B
Quick Check:
Protected mode = Limits connections [OK]
Hint: Protected mode restricts connections to protect Redis [OK]
Common Mistakes:
Thinking it improves performance
Confusing it with backup features
Assuming it allows open access
2. Which of the following is the correct way to disable protected mode in the Redis configuration file?
easy
A. protected-mode no
B. protected-mode yes
C. protected_mode no
D. disable-protected-mode true
Solution
Step 1: Identify the correct syntax for the setting
The Redis config uses protected-mode with a dash, not underscore or other variations.
Step 2: Determine the value to disable it
Setting protected-mode no disables protected mode.
Final Answer:
protected-mode no -> Option A
Quick Check:
Disable protected mode = protected-mode no [OK]
Hint: Use dash and 'no' to disable protected mode [OK]
Common Mistakes:
Using underscore instead of dash
Setting value to 'yes' to disable
Using invalid config keys
3. Given the Redis config snippet:
protected-mode yes
bind 127.0.0.1
What will happen if a client tries to connect from a remote IP?
medium
A. Connection will be rejected due to protected mode and bind settings
B. Connection will be accepted without restrictions
C. Redis will crash with an error
D. Connection will be accepted only if password is provided
Solution
Step 1: Analyze protected mode and bind settings
Protected mode is enabled and Redis is bound only to localhost (127.0.0.1).
Step 2: Understand remote connection behavior
Clients from remote IPs cannot connect because Redis listens only on localhost and protected mode blocks unsafe access.
Final Answer:
Connection will be rejected due to protected mode and bind settings -> Option A