redis使用日志(4):如何让外部服务器访问
2017-03-10 10:45
597 查看
开启redis 允许外网IP 访问
在 Linux 中安装了redis 服务,当在客户端通过远程连接的方式连接时,报could not connect错误。
错误的原因很简单,就是没有连接上redis服务,由于redis采用的安全策略,默认会只准许本地访问。
需要通过简单配置,完成允许外网访问。
修改redis的配置文件,将所有bind信息全部屏蔽
修改完成后,需要重新启动redis服务
如果iptables 没有开启6379端口,用这个方法开启端口
通过iptables 允许指定的外网ip访问
修改 Linux 的防火墙(iptables),开启你的redis服务端口,默认是6379。
未配置拒绝前
配置拒绝后
也可以用下面的方式:如果只是自己做个爬虫缓存的话
在 Linux 中安装了redis 服务,当在客户端通过远程连接的方式连接时,报could not connect错误。
错误的原因很简单,就是没有连接上redis服务,由于redis采用的安全策略,默认会只准许本地访问。
需要通过简单配置,完成允许外网访问。
修改redis的配置文件,将所有bind信息全部屏蔽
修改完成后,需要重新启动redis服务
redis-server redis.conf
如果iptables 没有开启6379端口,用这个方法开启端口
命令:/sbin/iptables -I INPUT -p tcp --dport 6379 -j ACCEPT 保存防火墙修改命令:/etc/rc.d/init.d/iptables save
通过iptables 允许指定的外网ip访问
修改 Linux 的防火墙(iptables),开启你的redis服务端口,默认是6379。
//只允许127.0.0.1访问6379 iptables -A INPUT -s 127.0.0.1 -p tcp --dport 6379 -j ACCEPT //其他ip访问全部拒绝 iptables -A INPUT -p TCP --dport 6379 -j REJECT
未配置拒绝前
配置拒绝后
也可以用下面的方式:如果只是自己做个爬虫缓存的话
# When protected mode is on and if: # # 1) The server is not binding explicitly to a set of addresses using the # "bind" directive. # 2) No password is configured. # # The server only accepts connections from clients connecting from the # IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain # sockets. # # By default protected mode is enabled. You should disable it only if # you are sure you want clients from other hosts to connect to Redis # even if no authentication is configured, nor a specific set of interfaces # are explicitly listed using the "bind" directive. protected-mode no # 默认是开启保护模式的yes,当设置成no的话,就直接能用了
相关文章推荐
- 如何使用C#访问POP3服务器(转)
- 如何配置和使用Tomcat访问日志
- 如何让更多用户使用远程桌面访问您的服务器
- [转]如何配置和使用Tomcat访问日志
- 如何让路由器外部的电脑能访问路由器内部的WEB服务器[TP-LINK]
- 如何使用C#访问POP3服务器
- Tomcat:如何配置和使用Tomcat访问日志
- .net asp iis服务器如何让外部访问自己的网站
- 如何从外部电脑访问服务器的Sqlserver 2005/2008 数据库
- 如何使用客户端访问安装在ubuntu上的mysql服务器
- 如何防止他人使用旧id和旧口令访问Domino服务器
- 如何使用花生壳让别人访问自己搭建的FTP服务器
- 使用外部表访问oracle告警日志
- 使用Nginx如何配置Tomcat访问日志记录真实IP
- 如何使用C#访问POP3服务器(英文)
- 使用Nginx如何配置Tomcat访问日志记录真实IP
- 使用外部表访问oracle告警日志
- 如何让路由器外部的电脑能访问路由器内部的WEB服务器[TP-LINK]
- 使用Nginx如何配置Tomcat访问日志记录真实IP
- 如何用服务器文件管理系统记录共享文件的访问日志、记录共享文件复制、修改、删除和剪切等操作?