Accessing a Remote Python Web Server on Amazon EC2

I am working on a project where I need a python web server. This project is hosted on Amazon EC2 (ubuntu). I made two unsuccessful attempts:

  • run python -m SimpleHTTPServer 8080

    . It works if I launch a browser on an EC2 instance and go to localhost: 8080 or <ec2-public-IP>: 8080. However, I cannot access the server from the browser on the remote machine (using <ec2-public-IP>: 8080).

  • create a python class that allows me to specify both an IP address and a port for serving files. Same problem as 1.

There are several questions on SO regarding the Python web server on EC2, but none seem to answer my question: What should I do to remotely access the python web server?

One more point: I don't want to use the Python web framework (Django or whatever): I will be using the web server to create a kind of REST API, not to host HTML content.

+3


source to share


2 answers


you should open port 8080 and ip restriction in security groups like:

All TCP TCP 0 - 65535 0.0.0.0/0



the last element means that this server will accept every request from any ip and port, you also

+4


source


You require IAM

AWS

. AWS

set security permissions that should open the port so you only localhost

bind your web service aws link



-2


source







All Articles