1

EC2에 두 개의 서버가 있습니다. 하나는 내 PHP 응용 프로그램을 호스팅하고 다른 내 redis 서버를 호스팅. 내가 redis 서버에서 내 PHP 세션 및 데이터를 관리하고 있습니다. 그래서 내 PHP 서버에서 나는 세션 저장 경로로 ip : port를 주었고 오류가 발생했습니다 : "PHP message : PHP 치명적 오류 : 잡히지 않은 예외 'RedisException'메시지가 'Connection closed'AWS EC2 포트 6381에 redis 서버를 연결할 수 없습니다.

나는해야합니다. 인바운드 트래픽에 대한 내 redis 인스턴스에서 포트 6379 열기 AWS 보안 그룹에서 사용자 정의 TCP 설정을 설정하여 열었지만 여전히 포트가 외부 세계와 연결되어 있지만 redis 서버 자체에서 포트를 수신 할 수 있습니다. i 과정에서 누락 된 부분이 있습니까? 다른 곳으로 변경해야합니까?이 부분을 안내해주십시오. AWS 관리를 처음 접했습니다. 인스턴스 1 : PHP, Apache 및 phpredis를 사용 중입니다. 인스턴스 2 : 사용 중 Redis

하지만 Memcache가 있습니다. d 포트 11211을 통해 아무 문제없이 연결하는 인스턴스 2에 설치됩니다. Redis에 대해 동일한 보안 규칙을 사용했습니다.

답변

5

기본적으로 redis는 127.0.0.1만을 수신하며 다른 인터페이스 나 노드에서 수신 대기하도록 redis에 명시 적으로 알려야합니다. 귀하의 배포판에 따라, 이것은 /etc/redis.conf 같은 어딘가에있을 수 있습니다.

redis가 모든 주소 (0.0.0.0)에서 수신 대기하도록하려면 redis.conf에 proetected-mode no을 설정해야합니다.

당신은 레디 스를 구성 할 때 는 신의 사랑에 대한 보안 그룹 설정에 있는지 확인하십시오, 당신은 포트가 만에 연결하는 데 필요한 PHP 서버의 IP 또는 보안 그룹에 열려 있는지 정의 redis, 그리고 전 세계에.

# 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 
:

참고로

, 여기 바인딩에 대한 redis.conf의 구성 부분이다