EC2 Port Listening with Elastic IP

I host 2 different flask applications with docker on EC2. One of them is running at port 80 and the other at port 5000.

My question is; Can I get a separate elastic ip for port 80 and a separate elastic ip address for port 5000 on AWS? Because if I don't get separate ip for these, I'm having problems with domain redirecting.

Upvotes: 0

Views: 830

Answers (2)

Asri Badlah
Asri Badlah

Reputation: 2123

No need to create and attach another NIC, you can assgin two IPs to the same interface:

  • Assigning a secondary private IPv4 address.
  • Configuring the operating system on your instance to recognize secondary private IPv4 addresses.
  • Associating an Elastic IP address with the secondary private IPv4 address.

See the following link: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/MultipleIP.html

After the discussion in comments, you should be binding to 0.0.0.0 if you want the container to be accessible from outside. If you have:

if __name__ == '__main__':
    app.run()

Change it to, in your both flask app

if __name__ == '__main__':
    app.run(host='0.0.0.0')

Upvotes: 2

karjan
karjan

Reputation: 1016

Yes, you just need multiple ENI https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-eni.html

Upvotes: 2

Related Questions