0

I have an ec2 instance on which I'm running a dev server via parcel index.html --host 0.0.0.0 that ultimately listens on 0.0.0.0:1234. Before creating and associating an eip to my instance, I wanted to use the public ip address assoc'd with it and modified my iptables via

sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 1234

This allowed me to visit my server via the browser using the public ip address assoc'd with my ec2 instance and receive the response I expect.

However, I've now created and assoc'd an eip with my instance (because it's a dev server and I start and stop the instance regularly, I want a constant ip address) and although I can continue to ssh into my instance via the eip address, I can't visit the server by using the eip address in my browser.

Since I'm able to ssh to the instance via the eip I wonder if there is some configuration local to the instance that I need to modify to make requests to my server.

Here are the inbound rules for the security group assoc'd with my instance. Security group inbound rules

geofflittle
  • 101
  • 1
  • I suspect this is something to do with iptables or your application, rather than AWS or elastic IPs. Once running EC2 is basically a standard Linux server. – Tim Aug 09 '20 at 19:41
  • 1
    That security group seems right. Are you sure your custom iptables rule is still present and effective? – Michael Hampton Aug 12 '20 at 02:02
  • @Michael Hampton It looks like that was the issue! Do those iptables rules get reset each time I stop and start the instance? Is there a way to make them constant? – geofflittle Aug 12 '20 at 02:40
  • Maybe like this, but there are different methods suggested that can be found via Google https://linuxconfig.org/how-to-make-iptables-rules-persistent-after-reboot-on-linux – Tim Aug 12 '20 at 03:16

0 Answers0