amazon-web-services - 从 VPC 内的 EC2 连接到 ElastiCache(VPC 外)实例

标签 amazon-web-services redis amazon-elasticache

我们有大量应用程序使用一个位于 VPC 外部的 ElasticCache 实例 (Redis)(经典实例)。有些应用程序位于 VPC 中,有些位于 VPC 之外(经典实例)。我们如何将所有应用程序连接到缓存?

我们可以毫无问题地将 VPC 外部的应用程序连接到缓存,因为缓存也位于 VPC 外部 VPC 内有少量应用无法连接到缓存。

谢谢。

最佳答案

VPC实例无法直接访问classic-cluster。解决方法是在经典实例上配置 NAT。

NAT需要有一个简单的tcp代理

YourIP=1.2.3.4
YourPort=80
TargetIP=2.3.4.5
TargetPort=22

iptables -t nat -A PREROUTING --dst $YourIP -p tcp --dport $YourPort -j DNAT \
--to-destination $TargetIP:$TargetPort
iptables -t nat -A POSTROUTING -p tcp --dst $TargetIP --dport $TargetPort -j SNAT \
--to-source $YourIP
iptables -t nat -A OUTPUT --dst $YourIP -p tcp --dport $YourPort -j DNAT \
--to-destination $TargetIP:$TargetPort

更多详情:https://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/Access.Outside.html

关于amazon-web-services - 从 VPC 内的 EC2 连接到 ElastiCache(VPC 外)实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38066908/

相关文章:

mysql - AWS MySQL 5.6.40 - 一次不知所措,永远不知所措

java - 从 Redis 中提取 key

reactjs - 使用 React Axios POST 请求时未设置 Express Session Cookie

amazon-web-services - elasticache如何复制配置组default.redis3.2以便更改一个参数而不写入103个未更改的键

ruby - AWS Elasticsearch 服务不断给出 'User anonymous' 错误

amazon-web-services - 如何在 Cloudformation 中获取区域 AWS API Gateway 的自定义域的目标域名?

lua - 在过期时以原子方式移动 redis key

java - 在 AWS Elasticache (Redis) 上使用 SAVE 命令的 Jedis

redis - ElastiCache Redis 服务器

amazon-web-services - Amazon Lightsail 实例是否托管/自动更新?