卷曲亚马逊 EC2 实例

编程入门 行业动态 更新时间:2024-10-26 20:21:04
本文介绍了卷曲亚马逊 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

  • 为什么会这样?
  • 如何才能使第二个命令也返回内容?
  • 推荐答案

    如果您需要通过寻址任何 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 实例

    本文发布于:2023-08-07 14:09:58,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1319521.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:亚马逊   卷曲   实例

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!