简体   繁体   English

在Amazon EC2上远程访问Python Web服务器

[英]Accessing Python webserver remotely on Amazon EC2

I work on a project in which I need a python web server. 我在一个需要python web服务器的项目上工作。 This project is hosted on Amazon EC2 (ubuntu). 该项目托管在Amazon EC2(ubuntu)上。 I have made two unsuccessful attempts so far: 到目前为止,我做了两次不成功的尝试:

  1. run python -m SimpleHTTPServer 8080 . 运行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. 如果我在EC2实例上启动浏览器并转到localhost:8080或< ec2-public-IP >:8080,它就可以工作。 However I can't access the server from a browser on a remote machine (using < ec2-public-IP >:8080). 但是,我无法从远程计算机上的浏览器访问服务器(使用< ec2-public-IP >:8080)。

  2. create a python class which allows me to specify both the IP address and port to serve files. 创建一个python类,它允许我指定IP地址和端口来提供文件。 Same problem as 1. 与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 ? 关于EC2上有关Python Web服务器的SO有几个问题,但似乎没有人回答我的问题:为了远程访问python Web服务器,我该怎么做?

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. 还有一点:我不想使用Python Web框架(Django或其他任何东西):我将使用Web服务器构建一种REST API,而不是用于提供HTML内容。

you should open the 8080 port and ip limitation in security croups, such as: 您应该在安全组中打开8080端口和IP限制,例如:

All TCP TCP 0 - 65535 0.0.0.0/0 所有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 最后一项表示此服务器将接受来自任何IP和端口的每个请求,您也是

You passble need to IAM in AWS . 您需要在AWS IAM Aws set security permission that need to open up port so you only localhost links your webservice aws link Aws设置需要打开端口的安全权限,以便您只有localhost链接您的webservice aws链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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