简体   繁体   中英

Accessing Python webserver remotely on Amazon EC2

I work on a project in which I need a python web server. This project is hosted on Amazon EC2 (ubuntu). I have made two unsuccessful attempts so far:

  1. run python -m SimpleHTTPServer 8080 . It works if I launch a browser on the EC2 instance and head to localhost:8080 or < ec2-public-IP >:8080. However I can't access the server from a browser on a remote machine (using < ec2-public-IP >:8080).

  2. create a python class which allows me to specify both the IP address and port to serve files. Same problem as 1.

There are several questions on SO concerning Python web server on EC2, but none seems to answer my question: what should I do in order to access the python web server remotely ?

One more point: I don't want to use a Python web framework (Django or anything else): I'll use the web server to build a kind of REST API, not for serving HTML content.

you should open the 8080 port and ip limitation in security croups, such as:

All TCP TCP 0 - 65535 0.0.0.0/0

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

You passble need to IAM in AWS . Aws set security permission that need to open up port so you only localhost links your webservice aws link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM