今天,本地连接远程服务器上的Redis,一直失败。
|
之前遇到过的几种情况,先排查下:
ip是否正确,输错了,还是不行。
密码,没有设置,还是不行。
检查服务器端口号,是否开放了,确实打开了。
用本地起了Redis,正常访问,所以怀疑是 不让远程访问。
研究了下,初步结论,没验证
1、bind 绑定ip
由于自己的ip,不稳定,不太好用
2、关闭保护模式
3、默认配置不懂,增加密码
最后,觉得都麻烦,所以为了长期安全发展,还是只让本地ip访问吧。
本地开发时,启动本地Redis。
#bind 127.0.0.1
70
71 # Protected mode is a layer of security protection, in order to avoid that
72 # Redis instances left open on the internet are accessed and exploited.
73 #
74 # When protected mode is on and if:
75 #
76 # 1) The server is not binding explicitly to a set of addresses using the
77 # "bind" directive.
78 # 2) No password is configured.
79 #
80 # The server only accepts connections from clients connecting from the
81 # IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain
82 # sockets.
83 #
84 # By default protected mode is enabled. You should disable it only if
85 # you are sure you want clients from other hosts to connect to Redis
86 # even if no authentication is configured, nor a specific set of interfaces
87 # are explicitly listed using the "bind" directive.
88 protected-mode yes
89
90 # Accept connections on the specified port, default is 6379 (IANA #815344).
91 # If port 0 is specified Redis will not listen on a TCP socket.
92 port 6379