我遇到了在Ubuntu上运行的python web服务器的可见性/可访问性问题。服务器代码如下:从外部机器访问python web服务器
#!/usr/bin/python
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
PORT_NUMBER = 8899
#This class will handles any incoming request from
#the browser
class myHandler(BaseHTTPRequestHandler):
#Handler for the GET requests
def do_GET(self):
self.send_response(200)
self.send_header('Content-type','text/html')
self.end_headers()
# Send the html message
self.wfile.write("Hello World !")
return
try:
#Create a web server and define the handler to manage the
#incoming request
server = HTTPServer(('', PORT_NUMBER), myHandler)
print 'Started httpserver on port ' , PORT_NUMBER
#Wait forever for incoming htto requests
server.serve_forever()
except KeyboardInterrupt:
print '^C received, shutting down the web server'
server.socket.close()
调用它本地使用curl下面命令工作 - 我收到的 'Hello World' 的答案。
curl {externalIP}:8899
在浏览器中打开地址(chrome,ie)失败!
http://{externalIP}:8899/
UFW的状态是不活动的
的iptables如下
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:8765
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Ubuntu已经Apache2的服务器上安装并使用网络浏览器,外部IP和端口80打开HTML文件正在与上面没有问题服务器...
任何想法我还能检查什么?
嗨。谢谢您的回答。不幸的是,在指定的代码行中将第一个参数更改为外部IP(并且在第二次尝试中为0.0.0.0)后,效果相同。局部卷曲作品,外部浏览器超时。 – user4738010
ping是否可以在另一台机器上工作?如果您从客户端telnet到端口8899,响应是什么? –
我用腻子(ssh)配置了所有东西,我可以ping ubuntu。更重要的是配置了apache2,我可以在html目录中查看html文档。我根本无法访问我的Web服务器。 – user4738010