5

Is there a way to connect Redis instance hosted on AWS from outside AWS network? I have one Windows based EC2 instance running on AWS and another one is Redis cache node.

I know this question has been asked but the answer is in context of Linux based system, but mine is Windows based server on AWS. I don't have enough score to post comments on existing questions. Here is the link to existing question on Stack Overflow:

Can you connect to Amazon Elasticache Redis outside of Amazon

Community
  • 1
  • 1
Manoj Aggarwal
  • 317
  • 2
  • 14
  • 1
    Ok, I figured it out. You can use netsh commands to setup TCP Proxy on Windows Server. Here is the link where I got help: http://www.sysbiosis.com/blog/set-tcp-proxy-windows By default REDIS runs on Port 6379. So in my Inbound ports on AWS Security Group, I defined another port (6377) and fired below command `netsh interface portproxy add v4tov4 listenaddress=LOCAL_IP_ADDRESS listenport=6377 connectaddress=IP_ADDRESS_OF_AWS_REDIS_INSTANCE connectport=6379` I hope it helps someone. Please don't forget to upvote, if it helps you. Can't post it as answer, bad score in my account. – Manoj Aggarwal Jan 08 '15 at 15:26
  • if you think that's fix your own problem, you can answer it, and mark it accepted. – BMW Jan 08 '15 at 20:09
  • I don't have enough numbers in my account to even answer my question and mark it accepted. Over designed by stack overflow :( – Manoj Aggarwal Jan 09 '15 at 17:20
  • why do you need to redirect/proxy ports? Are you running a local redis node too? – tedder42 Jan 09 '15 at 18:07
  • Redis on AWS are accessible from EC2 instances only, that is the reason I need port redirection from EC2 to REDIS instance. – Manoj Aggarwal Jan 10 '15 at 08:56

1 Answers1

2

Steps to access Elasticache Redis from outside of AWS.

1) Create an EC2 instance in same VPC as elasticache redis but the public subnet. Make sure that IP forwarding is enabled:

cat /proc/sys/net/ipv4/ip_forward

value ip_forward=1 indicates that forwarding is enabled

Make sure Masquerading is enabled: iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

2) Create security Group with Inbound connection on port that you intend to forward ( lets say 6379 in this case). Specify the source CIDR block for the incoming connection. Ensure that the outbound rule allows connection to the redis cluster on desired port(default redis port is 6379)

3) Add IP table rule to allow forwarding rule from EC2 instance to elasticache iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 11211 -j DNAT --to :6379

source

Anil
  • 56
  • 5
  • Link only answers are not appropriate as they tend to have no lasting value – Soren May 21 '17 at 17:16
  • Those are exact steps that you follow. It is not expected that you copy and paste the source if that's what you mean. – Anil May 21 '17 at 17:19
  • Link only answers are bad answers -- please read https://meta.stackexchange.com/questions/8231/are-answers-that-just-contain-links-elsewhere-really-good-answers – Soren May 21 '17 at 17:48
  • Got it. Now, I will describe the answer to avoid the negative posting. What do you say? – Anil May 21 '17 at 18:42
  • That sounds like an idea... you can click `edit` to describe and enhance your post. – Soren May 21 '17 at 20:00
  • @soren, Made updates, Thanks for feedback. You think you can unmark the negative review? – Anil May 23 '17 at 03:44