Score:0

In AWS how can I route outbound EC2 traffic through different Internet Gateways depending on the payload?

cn flag

I have a weird scenario where I need to route certain outbound traffic from an app hosted on EC2 through different regional IP addresses.

Long story short we have 2 clients with APIs that our app communicates with to POST data. We found that their firewalls are strict at times and eventually block us mostly because we are in a different country. After a lot of back and forth, I eventually cloned our EC2 instance in their region with an IP in their country and the problem went away instantly.

Since this test was successful we figured we could just use the main EC2 instance and use routing rules that detect data header/url and route the outbound traffic through a different internet gateway for these 2 clients.

What's the best way to achieve this in AWS?

vn flag
I have not tried this but perhaps you could create a VPC in "their" region (with associated internet gateway), establish a peering connection between it and your VPC, edit the relevant subnet's route table such that the IPs of the client's APIs are routed to the pcx...on 2nd thought that won't work. You would probably need an instance in that VPC to NAT and route traffic and an additional route directing client IPs to the instance.
Tim avatar
gp flag
Tim
The best way to achieve this is to have the client whitelist your static IP. Routing outbound traffic based on content is an unusual pattern. (Guessing) you might be best using a piece of software such as Nginx / Apache and two network interfaces which are routed differently via different subnets out through maybe a VPN to another AWS region. Unusual problem.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.