redis-doc-外网连接

修改redis.conf

1
2
3
4
5
6
7
8
9
10
# 打开redis.conf文件
vim /etc/redis.conf

# 找到
bind 127.0.0.1
protected-mode yes

# 修改为
# bind 127.0.0.1
protected-mode no

只允许某个ip连接

1
2
3
4
5
6
# 修改 Linux 的防火墙(iptables),开启你的redis服务端口,默认是6379。
# 只允许198.168.0.122访问6379
iptables -A INPUT -s 198.168.0.122 -p tcp --dport 6379 -j ACCEPT

# 其他ip访问全部拒绝
iptables -A INPUT -p TCP --dport 6379 -j REJECT