2016-12-27 22 views
1

EC2に2台のサーバーがあります。 1つは私のPHPアプリケーションをホスティングし、もう1つは私のredisサーバをホスティングする。私は自分のPHPセッションとデータを管理しています。私のPHPサーバ上では、私はセッション保存パスとしてip:portを与えて、stderrでエラーFastCGIを受け取りました: "PHPメッセージ:PHP致命的なエラー:メッセージが '接続が閉じられました'というキャッチされない例外 'RedisException'私のredisインスタンス上のポート6379を受信トラフィック用にオープンしました。AWSセキュリティグループでカスタムTCP設定を行ってもオープンしましたが、ポートは外部に閉じていますが、私はredisサーバ自体のポートを聞くことができます。私はこのプロセスの中で何かを見逃していますか?どこか他の変更を加える必要がありますか?私はAWS管理の初心者です インスタンス1:私はPHP、Apache、phpredisを使用しています インスタンス2:レディスAWS EC2ポート6381のredisサーバーに接続できません

しかし、私はMemcacheポート11211を介して接続しているインスタンス2にインストールします。私はRedisに同じセキュリティルールを使用しました

答えて

5

デフォルトでは、redisは127.0.0.1だけをリッスンし、他のインターフェイスまたは任意のノードでリッスンするように明示的に指示する必要があります。あなたのディストリビューションによっては、これは/etc/redis.confのようなものかもしれません。

さらに、redisがすべてのアドレス(0.0.0.0)でリッスンするようにする場合は、redis.confにproetected-mode noを設定する必要があります。

あなたはRedisのを設定する場合、は神の愛のためのセキュリティグループの設定に確認してください、あなたはポートがのみに接続する必要があるPHPサーバーのIPまたはセキュリティグループに開いていることを定義します赤ちゃんは、全世界にはない。参考のため

は、ここでの結合についてredis.confから構成セクションです:

# 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 
関連する問題