Blueprints · Docker & Databases
Redis or Valkey production security and persistence
Binds Redis to loopback, keeps protected mode, adds an ACL user, disables FLUSHALL, and turns on AOF plus RDB. The overcommit sysctl is set for the background save.
Why this should not be public
Redis was designed for trusted networks. Exposed instances are used to plant SSH keys through CONFIG SET dir, load malicious modules and run cryptominers, and 2026 added authenticated code-execution bugs such as CVE-2026-23479. Loopback plus an ACL user closes both paths.
Live config
Baked-in protections
- bind is 127.0.0.1 and ::1
- protected-mode stays on
- FLUSHALL is renamed to an empty command
- vm.overcommit_memory is 1
- AOF and RDB are both enabled
Step 1 · conf
redis.conf
/root/portgate-blueprints/redis.conf
The apply script refuses the default password. The default user is turned off.
bind 127.0.0.1 ::1 protected-mode yes port 6379 appendonly yes appendfsync everysec save 900 1 save 300 10 user default off user app on >change-me ~* &* +@all -@dangerous +info rename-command FLUSHALL "" rename-command FLUSHDB ""
Step 2 · bash
Apply when Redis is installed
/root/portgate-blueprints/redis-apply.sh
Also writes the overcommit sysctl. Valkey reads the same file when you point it at this path.
#!/bin/sh set -eu printf '%s\n' 'vm.overcommit_memory = 1' > /etc/sysctl.d/99-portgate-redis.conf sysctl -w vm.overcommit_memory=1 if [ "change-me" = "change-me" ]; then echo "Set REDIS_PASSWORD before copying redis.conf. The staged file was left in place." exit 0 fi if [ -d /etc/redis ]; then install -m 640 /root/portgate-blueprints/redis.conf /etc/redis/redis.conf systemctl restart redis-server || systemctl restart redis || systemctl restart valkey || true else echo "Redis is not installed. The conf file is staged under /root/portgate-blueprints." fi