I have this EC2 instance with private IP 172.31.11.204 and public IP 34.205.X.X My web service is running on private IP 172.31.11.204 and on port 31336.
- Inside EC2, I am able to access the service using
- From my computer, I'm able to access it using ec2 public IP and port 31336
But I am unable to access the service using port 80 i.e., curl 34.205.26.X:80
My Security group rule is perfectly fine.
Also, I tried with adding the with follwing nat rule in IPtables -
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 172.31.11.204:31336
sudo iptables -t nat -I PREROUTING --src 0/0 --dst 127.0.0.1 -p tcp --dport 80 -j REDIRECT --to-ports 31336
when I do tcpdump, I noticed the incoming connection is getting hit onto the above rule but the return traffic is stuck at 172.31.11.204.80
I have searched a lot but could not find any solution.