首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >无法连接AWS EC2端口6379上的redis服务器

无法连接AWS EC2端口6379上的redis服务器
EN

Stack Overflow用户
提问于 2016-12-27 10:00:42
回答 1查看 2.7K关注 0票数 1

我在EC2上有两个服务器。一个托管我的php应用程序,另一个托管我的redis服务器。我正在管理我的php会话和redis服务器上的数据。因此,在我的php服务器上,我给出了ip:port作为会话保存路径,并得到了在stderr中发送的错误FastCGI:"PHP消息: PHP致命错误:未指明的异常'RedisException‘与消息’连接关闭‘。

我需要为入站流量在redis实例上打开端口6379。我通过在AWS安全组中设置一个自定义TCP设置来打开它,但是端口仍然关闭。但是我能够监听redis服务器本身的端口。在这个过程中我有遗漏什么吗?我还需要在别的地方做什么改变吗。请给我带路。在实例1上,我对AWS管理非常陌生:我在使用php、Apache和phpredis (实例2:使用Redis )。

但是我已经在实例2上安装了Memcached,它通过端口11211连接,没有任何问题。我对Redis使用了相同的安全规则。

EN

回答 1

Stack Overflow用户

发布于 2016-12-27 12:29:45

默认情况下,redis只在127.0.0.1上侦听,您需要显式地告诉redis在其他接口或任何节点上侦听。取决于您的发行版,这可能是一个类似于/etc/redis.conf的地方。

除此之外,如果您想让redis监听所有地址(0.0.0.0),您应该在redis.conf中设置proetected-mode no

当您配置redis时,--为了上帝的爱--请确保在您的安全组设置中,您定义端口只对需要连接到redis的IP或服务器的安全组打开,而不是对整个世界开放。

作为参考,下面是redis.conf中关于绑定的配置部分:

代码语言:javascript
代码运行次数:0
运行
复制
# By default, if no "bind" configuration directive is specified, Redis listens
# for connections from all the network interfaces available on the server.
# It is possible to listen to just one or multiple selected interfaces using
# the "bind" configuration directive, followed by one or more IP addresses.
#
# Examples:
# 
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1 ::1
#
# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
# internet, binding to all the interfaces is dangerous and will expose the
# instance to everybody on the internet. So by default we uncomment the
# following bind directive, that will force Redis to listen only into
# the IPv4 lookback interface address (this means Redis will be able to
# accept connections only from clients running into the same computer it
# is running).
#
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bind 127.0.0.1

# Protected mode is a layer of security protection, in order to avoid that
# Redis instances left open on the internet are accessed and exploited.
#
# 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 yes
票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41342972

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档