Can you connect to Amazon ElastiСache Redis outside of Amazon?

后端 未结 9 1604
梦谈多话
梦谈多话 2020-12-02 05:56

I\'m able to connect to an ElastiCache Redis instance in a VPC from EC2 instances. But I would like to know if there is a way to connect to

相关标签:
9条回答
  • 2020-12-02 06:26

    SSH port forwarding should do the trick. Try running this from you client.

    ssh -f -N -L 6379:<your redis node endpoint>:6379 <your EC2 node that you use to connect to redis>
    

    Then from your client

    redis-cli -h 127.0.0.1 -p 6379
    

    It works for me.

    Please note that default port for redis is 6379 not 6739. An also make sure you allow the allow the security group of the EC2 node that you are using to connect to your redis instance into your Cache security group.

    Also, AWS now supports accessing your cluster more info here

    0 讨论(0)
  • 2020-12-02 06:28

    BTW if anyone wants a windows EC2 solution, try these at the DOS prompt (on said windows EC2 machine):

    To Add port-forwarding

    C:\Users\Administrator>netsh interface portproxy add v4tov4 listenport=6379 listenaddress=10.xxx.64.xxx connectport=6379 connectaddress=xxx.xxxxxx.ng.0001.use1.cache.amazonaws.com

    To list port-forwarded ports

    C:\Users\Administrator>netsh interface portproxy show all

    Listen on ipv4: Connect to ipv4:

    Address Port Address Port


    10.xxx.128.xxx 6379 xxx.xxxxx.ng.0001.use1.cache.amazonaws.com 6379

    To remove port-forwarding

    C:\Users\Administrator>netsh interface portproxy delete v4tov4 listenport=6379 listenaddress=10.xxx.128.xxx

    0 讨论(0)
  • 2020-12-02 06:33

    I resolved using this amazon docs it says you ll have to install stunnel in your another ec2 machine.

    https://aws.amazon.com/premiumsupport/knowledge-center/elasticache-connect-redis-node/

    0 讨论(0)
  • 2020-12-02 06:34

    Update 2018

    The previous answer was accurate when written, however it is now possible with some configuration to access redis cache from outside using the directions according to Accessing ElastiCache Resources from Outside AWS


    Old Answer

    No, you can't without resorting to 'tricks' such as a tunnel, which maybe OK for testing but will kill any real benefit of using a super-fast cache with the added latency/overhead.

    The Old FAQ under How is using Amazon ElastiCache inside a VPC different from using it outside?:

    An Amazon ElastiCache Cluster, inside or outside a VPC, is never allowed to be accessed from the Internet

    However, this language has been removed in the current faq

    0 讨论(0)
  • 2020-12-02 06:34

    Not so old question, I ran to the same issue myself and solved it:

    Sometimes, for developing reasons you need to access from outside (to avoid multi-deployments just for a simple bug-fix maybe?)

    Amazon have published a new guide that uses the EC2 as proxies for the outside world:

    https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/accessing-elasticache.html#access-from-outside-aws

    Good luck!

    0 讨论(0)
  • 2020-12-02 06:36

    These answers are out of date.

    You can access elastic-cache outside of AWS by following these steps:

    1. Create a NAT instance in the same VPC as your cache cluster but in a public subnet.
    2. Create security group rules for the cache cluster and NAT instance.
    3. Validate the rules.
    4. Add an iptables rule to the NAT instance.
    5. Confirm that the trusted client is able to connect to the cluster.
    6. Save the iptables configuration.

    For a more detailed description see the aws guide:

    https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/accessing-elasticache.html#access-from-outside-aws

    0 讨论(0)
提交回复
热议问题