卷曲亚马逊 EC2 实例 [英] Curl amazon EC2 instance

查看:39
本文介绍了卷曲亚马逊 EC2 实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Web 服务器在端口 3000 的 Ubuntu Amazon EC2 实例上运行.15.0.0.10 是此 EC2 实例的私有 ip.

I have a web server running on an Ubuntu Amazon EC2 instance at port 3000. 15.0.0.10 is the private ip of this EC2 instance.

在我通过 ssh 进入这个实例并运行以下命令 curl localhost:3000/index.html 后,它会返回我的 index.html 页面的 html 源代码.

After I ssh into this instance and run the following command curl localhost:3000/index.html, it returns me the html source of my index.html page.

但是当我运行 curl 15.0.0.10:3000/index.html 时,它说:

But when I run curl 15.0.0.10:3000/index.html, it says :

curl: (7) couldn't connect to host

  1. 为什么会这样?
  2. 如何才能使第二个命令也返回内容?

推荐答案

如果您需要通过寻址任何 IP 来访问服务器,您需要确保服务器在 0.0.0.0 上运行实例.

You need to ensure that the server is running on 0.0.0.0 if you need it to be reachable by addressing any IP of the instance.

如果您已在 localhost (127.0.0.1) 上启动它,则该行为是正常的.您可以停止服务器并重新启动它以绑定到 0.0.0.0:3000.一切正常.

If you have started it on localhost (127.0.0.1), then the behavior is expected. You can stop the server and re-start it to bind to 0.0.0.0:3000. Things should work.

这篇关于卷曲亚马逊 EC2 实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆