我正在远程服务器上运行Python服务器:
server_class = BaseHTTPServer.HTTPServer
httpd = server_class(("127.0.0.1", 80), MyHandler)
httpd.serve_forever()
httpd.server_close()
从服务器,我可以进行查询:“curl -i localhost”,它运行正常。但是,从远程计算机我不能,即使没有防火墙。
curl: (7) Failed to connect to aa.bb.cc.dd port 80: Connection refused
我正试图通过服务器的IP地址来做到这一点。
答案 0 :(得分:1)
当然你不能。您将服务器绑定到仅127.0.0.1本地地址,因此它只能回答本地查询。使用特殊的0.0.0.0
地址允许它在任何接口上应答:
httpd = server_class(("0.0.0.0", 80), MyHandler)